Zod validation on forms vs fields #1586
Unanswered
iSpeakNerd
asked this question in
General
Replies: 1 comment
-
Standard schema issues are objects with a Field validator errors (should) take precedence over form validator errors, and I'm able to recreate it on a stackblitz example. |
Beta Was this translation helpful? Give feedback.
0 replies
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 was following along with https://www.youtube.com/watch?v=Pys2ExswZT0 and https://www.youtube.com/watch?v=HSboMHfPuZA from Balastrong's stuff when I found some interesting behavior.
Using a Zod schema (any schema?) for the whole form will overwrite inline validation behavior on form fields.
ex.
this custom field validation on confirmPassword
gets ignored in favor of the zod form schema for that field
confirmPassword: z.string()
and so the custom error gets ignored and not displayed to user.===================================
We can use only inline zod for fields (and do a check for field errors on form state onSubmit/onBlur) or use Zod to add the similar confirmPassword behavior as shown in the tutorial.
Beta Was this translation helpful? Give feedback.
All reactions