How to get latest form errors from zod validations in mode: 'all' #8553
Unanswered
JohannesKlauss
asked this question in
Q&A
Replies: 2 comments 4 replies
-
|
Beta Was this translation helpful? Give feedback.
3 replies
-
Hello, I have a same problem, do you have an answer ? thanks |
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.
-
I have this codesandbox:
Codesandbox
I am validating with zod that an array of objects holding numbers has a nonnegative required value.
And I am validating on that array that the sum of those numbers is 100.
I am listening to changes to the
formState.errors
to check if the latest errors occur there.But when I for example enter the values 20, 20, 50 no errors appear, even though the sum is 90. Zod validation is triggered but the error object is stale. It also doesn't trigger errors when I enter the first value with the other two inputs empty (which should trigger an error for not filling required fields).
If I click on the submit button everything is correctly validated and populated, but not during onChange.
Is this a bug or am I missing something here?
Beta Was this translation helpful? Give feedback.
All reactions