TanStackT
TanStack2y ago
4 replies
popular-magenta

Conditionally require field(s) using ZOD

I have some fields that are only required once the user checked a Checkbox

Here's a reproduction: https://stackblitz.com/edit/tanstack-form-cuevyr?file=src%2Findex.tsx

Questions:
1) Is there a way to react to the Checkbox being checked/unchecked and then setting the "address"-Object to undefined? Is that the way to do it?
2) Why isn't the formErrorMap displaying the Errors?
StackBlitzPascal Küsgen
Run official live example code for Form Zod, created by Tanstack on StackBlitz
Form Zod Example (forked) - StackBlitz
Was this page helpful?