Skip to content

Instantly share code, notes, and snippets.

@sbalay
Created January 26, 2017 00:01
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 sbalay/4473a105578c58e3c99362db1dd3db4d to your computer and use it in GitHub Desktop.
Save sbalay/4473a105578c58e3c99362db1dd3db4d to your computer and use it in GitHub Desktop.
Form level validations with redux form
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