Skip to content
Discussion options

You must be logged in to vote

No, you are wrong.
This is normal that coerce method uses the standard javascript conversions rules.

Go read the documentation: https://zod.dev/?id=coercion-for-primitives
Particularly this part:

This is exactly what I explained to you.

If you find these rules illogical, go blame javascript specification writers. ;)
But if you want different conversion rules, you'll have to implement them yourself like in my previous example.

Regards.

Replies: 12 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by JacobWeisenburger
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@scotttrinh
Comment options

@vtgn
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
8 participants
Converted from issue

This discussion was converted from issue #3328 on March 15, 2024 16:11.