Skip to content

Instantly share code, notes, and snippets.

@msaaddev
Created August 23, 2019 17:25
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 msaaddev/d65fe91558bdfec4e1a5706ca90ef4a1 to your computer and use it in GitHub Desktop.
Save msaaddev/d65fe91558bdfec4e1a5706ca90ef4a1 to your computer and use it in GitHub Desktop.
validate = () => {
const options = { abortEarly: false };
const { error } = Joi.validate(this.state.data, this.schema, options);
if (!error) return null;
const errors = {};
for (let item of error.details) errors[item.path[0]] = item.message;
return errors;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment