Custom Validator: Setting errors on fields inside useFieldArray
#11442
Unanswered
lordkerwin
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Hi Sean, I am facing the same problem, have you managed to solve it? |
Beta Was this translation helpful? Give feedback.
1 reply
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.
-
We have a custom schema built using TypeBox, but for legacy package reason, we can't use the typebox resolver.
Our schema is quite complex, but I've built a custom resolver to validate and return errors.
For top level field errors, they work and appear. But for anything nested/created under a
useFieldArray
, I can't for some reason, set the errors.Currently my
useForm
looks like this.My validate function is like this:
now, in the resolver, if the
validateFormSchema
returns errors, they're Typebox/Ajv style errors like this.Which is fine, as in my form, there's a
useFieldArray
forconfig.routes
and then nested inside that is another for theconfig.routes.0.cards
.Appending, updating and removing things using the fieldArray is fine, that all works. and the form does stop submission is the data is invalid, but it just doesn't parse down the errors to the components, no matter what I try.
I'm just wondering if there's something in my resolver that im doing wrong when returning the errors.
I have this bit
const _path = currentError.instancePath.substring(1).replace(/\//g, ".");
which changes/config/routes/0/cards/1/card/flowId
toconfig.routes.0.cards.1.card.flowId
to use as thekey
for the errors object.Any help would be greatly appreciated, sorry I can't share my entire form schema as its huge and broken over multiple files.
Beta Was this translation helpful? Give feedback.
All reactions