im trying to validate emails with zod and have errors for when its required and invalid for example z .object({ email: z.email({ required_error: "Email is required.", invalid_type_error: "Email is invalid.", }),
this is what im doing currently but i dont get this to show the required error when the field is blank! what am i messing up? ive looked into the docs but cant get to see the issue
in the zod docs we have this
so i tried doing
z .object({ email: z.email({ error: (issue) => issue.input === undefined ? "Email is required" : "Invalid email", }),
z .object({ email: z.email({ error: (issue) => issue.input === undefined ? "Email is required" : "Invalid email", }),
but i still get the latter error instead of email is required