I have a NumberInput component that accepts either a number or an empty string (for invalid or empty input). I would like to model this in zod using z.number().or(z.literal("")), but this gives the error message
No matching zod schema for type ZodUnion found in mapping for property <property>. Make sure there's a matching zod schema for every property in your schema.
I see that discriminated unions are supported. I'd love to be able to use regular unions, too.
I have a
NumberInput
component that accepts either anumber
or an empty string (for invalid or empty input). I would like to model this in zod usingz.number().or(z.literal(""))
, but this gives the error messageI see that discriminated unions are supported. I'd love to be able to use regular unions, too.