Created
September 8, 2017 21:30
-
-
Save JoaoCnh/a83e22b0e8ed1f52c8317c32d09aa10f to your computer and use it in GitHub Desktop.
Yup Validation 3
This file contains hidden or 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
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