Skip to content
Discussion options

You must be logged in to vote

The issue is that when you use form-level Zod validation combined with field-level onChangeListenTo, errors from the Zod schema get mapped to fields based on the Zod path — and when field a is empty/invalid, Zod's error for a can end up bleeding into field b because the form-level validator runs for both fields.

The root of the problem is that z.iso.date() on field a produces an error with path ['a'], but because your b field listens to a via onChangeListenTo: ['a'], it also re-validates when a changes. The form-level validator runs and its errors are distributed across fields — sometimes incorrectly.

Fix: Separate form-level and field-level concerns

Don't mix form-level Zod schema valida…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by dikue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants