Created
January 26, 2017 00:01
-
-
Save sbalay/4473a105578c58e3c99362db1dd3db4d to your computer and use it in GitHub Desktop.
Form level validations with redux form
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 default reduxForm({ | |
form: 'signIn', | |
validate: (values) => { | |
const errors = {}; | |
errors.email = !values.email | |
? 'Email field is required' | |
: !emailRegex.test(values.email) | |
? 'Email format is invalid' | |
: undefined; | |
errors.password = !values.password | |
? 'Password field is required' | |
: values.password.length < 8 | |
? 'Password must be at least 8 characters long' | |
: undefined; | |
return errors; | |
} | |
})(MyForm); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment