We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
So I have been using this Country enum and wondering if we can validate the keys instead of the value?
https://gist.github.com/evolkmann/740d24889c509c08484a8ff72af5dd64
Currently, the nativeEnum validates the value and could not find an option to make it validate the key instead.
The text was updated successfully, but these errors were encountered:
Currently using this as I cannot flip the enum just for Zod
z.string().length(2).regex(/^[A-Z]{2}$/, 'Invalid country code').nullable()
Sorry, something went wrong.
This how I did it
z.enum(Object.keys(Enum) as [keyof typeof Enum, ...(keyof typeof Enum[]])
Let me know if you have a better idea than this.
No branches or pull requests
So I have been using this Country enum and wondering if we can validate the keys instead of the value?
https://gist.github.com/evolkmann/740d24889c509c08484a8ff72af5dd64
Currently, the nativeEnum validates the value and could not find an option to make it validate the key instead.
The text was updated successfully, but these errors were encountered: