Best way to create a zod validator for a list of literal strings #2890
Answered
by
JacobWeisenburger
SonofNun15
asked this question in
Q&A
-
I want to do something like this:
Goal is to create a list of literal strings and enforce that the property contains one of these strings. I could certainly do:
But I want to have an array of these values that I can render as the options for a select input. That map doesn't work because the type definition for Any suggestions on the best way to proceed? This issue is similar: But I can't imagine using ~100 lines of code for this. |
Beta Was this translation helpful? Give feedback.
Answered by
JacobWeisenburger
Oct 20, 2023
Replies: 1 comment
Answer selected by
SonofNun15
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/colinhacks/zod#zod-enums