Why does form level validate errors not propagate down to fieldState.error for given field #13856
Replies: 3 comments
|
The current implementation puts errors returned by If the error belongs to the field, use its |
|
The TypeScript complaint about I've submitted a scoped type fix in #13860, with a regression that fails on the original declarations. All type checks, 1,552 unit tests and 90 browser tests passed locally; the PR's six CI checks also passed. It still needs maintainer review. The field-state behavior described above remains a separate API-design question. The proposed type fix makes the existing |
|
That's by design, not a bug: the form-level From the docs (useForm Options:
So your observation is expected; use If this clears it up, please mark this comment as the answer — thanks! |
Uh oh!
There was an error while loading. Please reload this page.
at the form level I have tried using the new validate Api...
I would expect the fieldState error for my field to reflect this error, but it is only available through formState.errors.form.myField
this error is undefined and I can only access it like this instead
so now i have field level validation rules and form level validation rules, but I would expect them to both propagate down the fieldState error. In addition typescript complains about this because the 'form' property on formState.errors.form comes back as Partial<{ type, message >} instead of a Record<string, Partial<{ type, message }>
am I missing something , What is the point of returning field level errors from the form level validation if they arent proagating the error down to the field.
All reactions