Skip to content

Instantly share code, notes, and snippets.

@JoaoCnh
Created September 8, 2017 21:30
Show Gist options
  • Save JoaoCnh/a83e22b0e8ed1f52c8317c32d09aa10f to your computer and use it in GitHub Desktop.
Save JoaoCnh/a83e22b0e8ed1f52c8317c32d09aa10f to your computer and use it in GitHub Desktop.
Yup Validation 3
Yup.object().shape({
email: Yup.string().email('Invalid email address').required('Email is required!'),
username: Yup.string().required('This man needs a ${path}').when('email', (email, schema) => {
if (email === '[email protected]') {
return schema.label('papidipupi').min(10);
}
return schema.label('babidibiba');
}).test('is-zigzagging', '${path} is not zigzagging', value => value === 'zigzagging'),
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment