Skip to content

.refine and .regex prevent .parse from returning .default value #3696

Answered by marilari88
MNeverOff asked this question in Q&A
Discussion options

You must be logged in to vote

hi @MNeverOff, in the first schema, when name is undefined, the val inside the refine has 'New Object' string and it fails because of the whitespace not matching the regex. Take a look a this playground: Zod playground with refine

Same behaviour we have with .regex() Zod playground with regex

So wrapping up it seems like the default value is passed to regex and refine validations

Additionally, verify the enum syntax: it necessitates an array as an argument.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@MNeverOff
Comment options

Answer selected by MNeverOff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants