Dealing with form input with z.coerce.date
Hey guys,
How do I make z.coerce.date() required, with zod and react hook form
4 Replies
TS Playground - An online editor for exploring TypeScript and JavaS...
The Playground lets you write TypeScript or JavaScript online in a safe and sharable way.
Or do you want it to fail on undefined rather than trying to coerce it?
I want the user to enter any date, but when they enter it the error disappears
this date does not need to have a conditional. it just needs to be filled
Oh, yeah, this is probably an issue because "required" means something different in TypeScript/Zod than in HTML forms.
"empty" in HTML forms is
""
where it's undefined
in TypeScript/Zod.
I don't have any direct advice to give here tho.
You can probably use something like: