Last active
January 26, 2017 20:09
-
-
Save sbalay/da6b33ab1cce49190f74d9ddd7a4c468 to your computer and use it in GitHub Desktop.
Async validations example of 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', | |
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