Add option excludeEmptyString for regex validators and z.e164()
#6206
evgeniyworkbel
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Yup has the option https://github.com/jquense/yup#stringmatchesregex-regex-options--message-string-excludeemptystring-bool--schema
I'm so waiting for this option in Zod because now custom validators looks confusable and not readable at all.
For example:
const latinTextOptionalValidator = z.string().regex(/^[A-Za-z]*/, "Text must contain latin letters").or(z.literal("")). This validator is hard to read, also I can't chain it withmin()ormax()It's simple example, but in real development there are more complicated validators.
So it will be very nice if this option appears
All reactions