Skip to content

Instantly share code, notes, and snippets.

@sbalay
Last active January 26, 2017 20:09
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/da6b33ab1cce49190f74d9ddd7a4c468 to your computer and use it in GitHub Desktop.
Save sbalay/da6b33ab1cce49190f74d9ddd7a4c468 to your computer and use it in GitHub Desktop.
Async validations example of redux form
export default reduxForm({
form: 'signIn',
asyncValidate: (values) => {
return new Promise((resolve, reject) => {
// simulate request
setTimeout(() => {
if (values.email.indexOf('@wolox.com') === -1) {
reject({ email: 'Only mails at wolox are allowed' });
} else {
resolve();
}
}, 1000);
});
},
asyncBlurFields: ['email'],
shouldAsyncValidate: (params) => {
return params.trigger === 'blur' && params.syncValidationPasses; // do not async validate on submit
}
})(MyForm);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment