Open romeovs opened 6 years ago
We're experiencing the same issue.
Especially the fact that the API needs to return undefined
values in the array for all the fields without errors is very different to how errors are otherwise handled.
As suggested by @romeovs, it would be great, if errors could be accessed by string notation "quu[0].qux"
instead of having to actually nest the errors in the errors object.
Are you submitting a bug report or a feature request?
A feature request
What is the current behavior?
The way errors structured currently mimics the way the values are being "nested".
For instance, say we have these fields:
This would serialize to the following values:
This works well for values! For errors however, we also need to pass them from the validator in the shape of the values object (according to your comments here). So for instance, to show an error on the field in
quu[0].qux
the errors returned from the validator need to be in this shape:Where showing an error on the
foo.bar
field just works:I think this API could do with a bit more consistency for a couple of reasons.
"foo.bar"
on the errors just worked, I expected"quu[0].qux"
to work as well, but it did not.undefined
items to the error array.Would it be hard to support the following structure for array errors?
Sandbox
The following sandbox has the working version and the non working version next to each other. Change
validate
toworks
on the<Form validate={} />
prop to see the difference. https://codesandbox.io/s/53rvj9p39nWhat's your environment?
Other information