Zod enums with any literals?
See original GitHub issueHi!
Is it possible to extend the functionality of zod enums to any literal, not just strings?
Examples of using:
z.enum([true, false, 'unknown'])
z.enum([400, 401, 404, 405, 500])
Issue Analytics
- State:
- Created 2 years ago
- Comments:9
Top Results From Across the Web
v3 string only allowed for enums · Issue #338 · colinhacks/zod
See: Should be allowed to do numbers for enums. ... approach, but consider maybe separating Zod Enums (unions of literals) more distinctly ...
Read more >Untitled
What is Zod Zod is a TypeScript-first schema declaration and validation library. I'm using the term "schema" to broadly refer to any data...
Read more >Zod: create a schema using an existing type - Stack Overflow
@Dotan, have you found a way to do this directly with existing types or maybe another way that doesn't require using a Zod...
Read more >zod - npm
Enums ; Intersections; Tuples; Recursive types ... Currently there is no support for Date or bigint literals in Zod.
Read more >How to extend enums in TypeScript - LogRocket Blog
TypeScript enum best practices. We have discussed how we can extend enums in Typescript, but enums aren't a magic bullet to be used...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Per-schema error handling is definitely an issue we are already looking at (see #97), and I see that you’ve commented there already, so yeah, I’ll close this and we can track toward a better solution for the error handling there.
Thanks for answers!
Do I need to open an issue?
Do I need to close this?