Validating array inputs based on another field from within the array #11979
Unanswered
PaulSusset
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In the following code snippet, I'm trying to require the province field only if the contents of the country field is
Canada
orUS
.Given this is an array of objects, using getValues() or useWatch() does not seem pertinent as I am unable to match to index dynamically.
I was hoping the validate function would provide current value's path or index, but without it I don't know how to make this possible.
Any help is appreciated
Of course I could just have the validation object directly in the field, but this code is an abstraction of a more complicated generic registration function, which I am trying to make work by passing a validation object to.
Generic register code
Beta Was this translation helpful? Give feedback.
All reactions