Search
Star
Feedback
Setup for Free
© 2026 Hedgehog Software, LLC
Twitter
GitHub
Discord
System
Light
Dark
More
Communities
Docs
About
Terms
Privacy
Zod array with valid values - Theo's Typesafe Cult
TTC
Theo's Typesafe Cult
•
3y ago
•
4 replies
Liam
Zod array with valid values
How can I make a zod array with certain valid values
. I know I could do this with refine
, but generally try to avoid that if possible to get better types
.
Thanks
!
Solution
This seems to work
z.
array
(z.
union
([z.
literal
(
"NY"
), z.
literal
(
"FL"
)]))
z.
array
(z.
union
([z.
literal
(
"NY"
), z.
literal
(
"FL"
)]))
Jump to solution
Theo's Typesafe Cult
Join
26,131
Members
View on Discord
Resources
ModelContextProtocol
ModelContextProtocol
MCP Server
Similar Threads
Was this page helpful?
Yes
No
Similar Threads
Zod one or more values from an array
TTC
Theo's Typesafe Cult / questions
4y ago
Validating array using zod
TTC
Theo's Typesafe Cult / questions
3y ago
Zod array of dates
TTC
Theo's Typesafe Cult / questions
4y ago
zod array still required?
TTC
Theo's Typesafe Cult / questions
4y ago