Created
April 27, 2020 07:41
-
-
Save palanisamym14/aa9c03a72a43f1584255faf340950b8f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const ValidateSchema = (values, schema) => { | |
return new Promise((resolve, reject) => { | |
const { value, error } = schema.validate(values); | |
const valid = error == null; | |
if (valid) { | |
resolve(value); | |
} else { | |
const { details } = error; | |
const message = details.map((i) => i.message).join(","); | |
reject(message); | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment