Open zkhan93 opened 3 days ago
Please add support for z.union() in validation schemas for shadcn Vue. Currently, using z.union() to handle multiple types (e.g., z.string().email() and z.literal('') for optional/nullable fields) is not supported, which limits flexibility.
z.union()
z.string().email()
z.literal('')
For example, this schema for an optional email:
email: z.union([z.literal(''), z.string().email().optional()])
renders nothing, likely skipping the field altogether.
Using this:
email: z.string().email().optional()
renders an email field, but when the value is removed, it still shows an invalid email error.
This issue on the Zod repo explains how to define an optional email field using z.union() for proper validation.
Describe the feature
Please add support for
z.union()
in validation schemas for shadcn Vue. Currently, usingz.union()
to handle multiple types (e.g.,z.string().email()
andz.literal('')
for optional/nullable fields) is not supported, which limits flexibility.For example, this schema for an optional email:
renders nothing, likely skipping the field altogether.
Using this:
renders an email field, but when the value is removed, it still shows an invalid email error.
This issue on the Zod repo explains how to define an optional email field using
z.union()
for proper validation.Additional information