-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Passing "contextual" data into validation method #51
Comments
👋 @jmeas I think your suggested workaround is fine, albeit a little cumbersome from an API standpoint. I do think that there could be value in passing contextual data as well. Ideally, it would easy to use manually like your example and also work well with redux-form. I've been a little busy finishing up some features for another OSS project, but I hope to come back and work on revalidate some more soon. If you have any ideas, I'd love to see them and maybe a PR too :) |
👌 I'll whip up a PR! |
👋 @jfairbank !
I often need to validate a field based on some information outside of any of the fields being validated. That's what I mean by "contextual" data in this issue's title. For instance, in a web app that manages books, you may want the books to have a unique name. So to validate the name of one book, the validation method needs all books to know if there is a duplicate.
To do this, would you recommend putting this "extra" data in the object to validated, and then not adding any validation on that key within
combineValidators
?To give an example, using the dog example from the docs:
Do you think this is fine, or do you have another suggestion on how best to do this? Thanks!
At first, I tried to do...
but that didn't work :)
The text was updated successfully, but these errors were encountered: