-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
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
Feature: support multiple parameters in .startsWith()
#3683
Comments
You can do it cleaner with regex: const schema = z
.string()
.regex(/^foo_|bar_|baz_/) I'll admit that using |
@tristinDLC yes I know, but using regex always hides the intention. But I would also close this issue if this would add too much complexity for not enough value to zod. |
I've submitted a PR to add support for multiple parameters in the .startsWith() and .endsWith() methods for string validation. |
…h() in string for ticket colinhacks#3683
Currently it quite verbose to define a string that can start with multiple different prefixes:
it would be great if
.startsWith()
would support an array of strings likemaybe I am also missing an alternative solution for the problem.
The text was updated successfully, but these errors were encountered: