iway1 / react-ts-form

https://react-ts-form.com
MIT License
2.01k stars 33 forks source link

Add support for ZodUnion #139

Open BrendanC23 opened 7 months ago

BrendanC23 commented 7 months ago

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.