-
-
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
Error when validating an existing email with hyphen (-) symbols when having a subdomain #2540
Comments
seeing this as well |
@AllanSimoyi the regex that I had wrote in PR #1982 was changed with another |
I've inspected the latest released package 3.21.4, and it's using the regex However, I've noticed that this has been switched out in the current codebase with the regex I dunno when the next version rolls out, but on paper, this change should address the issue we're seeing |
@phil-loops the current regex you send doesn't validate the presence of hyphens (-) on all scenarios after the first dot (.) Is there anything we can do to fix it? |
@rafaell-lycan to get the zod regex modified, you'd have to submit a PR and wait for the next package to come out. Otherwise, if you want to roll your own email validation, you could do something like |
@phil-loops for now I'm using a custom Regex which is the previous one used at For anyone else looking for a fix with previous email regex: const EMAIL_REGEX = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|([^-]([a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}))$/;
z.string().regex(EMAIL_REGEX) |
I'm also seeing this- any progress on a fix? |
This is fixed in https://github.com/colinhacks/zod/releases/tag/v3.22.0 |
Hi,
I'm getting a strange error when parsing an email that contains a hyphen (-) when having a subdomain:
Example of a valid email:
Error:
This started happening when upgrading from
3.20.x
to3.21.x
The only I could think about was to use a Regex instead:
Any ideas or workaround on it?
The text was updated successfully, but these errors were encountered: