Skip to content

Instantly share code, notes, and snippets.

@palanisamym14
Created April 27, 2020 07:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save palanisamym14/aa9c03a72a43f1584255faf340950b8f to your computer and use it in GitHub Desktop.
Save palanisamym14/aa9c03a72a43f1584255faf340950b8f to your computer and use it in GitHub Desktop.
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