Skip to content

Validate array when the subField value chages, how to do it? #743

Closed Answered by Balastrong
samuellawerentz asked this question in Q&A
Discussion options

You must be logged in to vote

Let's look at the generic case, you have an array of objects and you're trying to run the onChange validator of the parent when values nested in the child are changed. If I got that right, what you'd need here is the onChange validation to bubble up to its parents.

Something similar but more precise (validating X while Y changes) can be achieved through Linked Fields but as of today you cannot easily link an entire array at one go.

In this specific case I'd go by manually running the validator when changing names but we might think of a new dedicated API for similar cases (like linking to entire arrays at one go).

Try by adding field.validate('change') there:

<form.Field key={i} name={`pe…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by samuellawerentz
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants