Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

Conversation

@marco-carvalho
Copy link

@marco-carvalho marco-carvalho commented Jun 30, 2025

Fixes #4362

@marco-carvalho marco-carvalho changed the title z.looseEnum() for more permissive enum validation Add z.looseEnum for more permissive enum validation Jun 30, 2025
@samchungy
Copy link
Contributor

Just putting this comment from the last PR here for visibility: #4391 (comment)

@marco-carvalho
Copy link
Author

hi @colinhacks WDYT about this PR?

@colinhacks
Copy link
Owner

Hesitant to add a new top-level type for a quite niche use case. I evaluated ways of folding this into $ZodEnum but it was just hairy enough to dissuade me.

Zod 4 already lets you further refine the inferred type of z.string() with a hand-written generic. Given the relative obscurity of this use case, I think this is more than adequate:

Image

@colinhacks colinhacks closed this Dec 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

z.looseEnum() for more permissive enum validation

3 participants