You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Based on the type the schema validation in the schema above adjusts.
type === 'my-optional-number' => foo validates to number
type === 'my-string' => foo validates to string
type === 'my-enum' => foo validates to enum
type === 'nothing' => foo validates to never
Is your feature request related to a problem? Please describe.
When creating dependent forms it would be nice to express the form dependencies via Zod.
Describe the solution you'd like
z.discriminatedUnion
allows us to do this in a nice matter.Based on the
type
the schema validation in the schema above adjusts.Describe alternatives you've considered
https://www.shadcn-vue.com/docs/components/auto-form.html uses a second dsl (dependencies) to solve the issue in a different way. But this approach creates the need to describe the dependencies via second api.
This makes the schema itself useless for the other tasks.
Here is an example using react-hook-forms that implements such a logic.
The text was updated successfully, but these errors were encountered: