Last active
February 10, 2017 01:44
-
-
Save ademidoff/f022443cb48bb4cf6c66ea851e588623 to your computer and use it in GitHub Desktop.
Redux Form Async Validation
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('@gmail.com') === -1) { | |
reject({ email: 'Only mails at gmail 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