Z
Zod7mo ago
Gludek

Gludek - Just to confirm z.string().email() can...

Just to confirm z.string().email() can't be combined with .nullish() right?
Solution:
Perhaps you're looking for:
const schema = z.literal("").or(z.string().email());
const schema = z.literal("").or(z.string().email());
...
Jump to solution
6 Replies
Sikari
Sikari7mo ago
I don't see why it wouldn't be able to, nullish just adds undefined | null to the type.
Gludek
GludekOP7mo ago
yeah, but regex validation of .email makes it so it needs to be defined, and null/undefined input is treated as invalid
Gludek
GludekOP7mo ago
No description
No description
Sikari
Sikari7mo ago
Your form most likely is not passing null or undefined, most likely you have ""
Solution
Sikari
Sikari7mo ago
Perhaps you're looking for:
const schema = z.literal("").or(z.string().email());
const schema = z.literal("").or(z.string().email());
Gludek
GludekOP7mo ago
okay that works
Want results from more Discord servers?
Add your server