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
Hi there,
I noticed the z.string().email() fails when the email contains an ampersand sign. This should be allowed.
Example: z.string().email().parse("test&[email protected]")
z.string().email().parse("test&[email protected]")
The text was updated successfully, but these errors were encountered:
It looks like this was supported at one point. But it was removed.
Sorry, something went wrong.
Per #2157 Zod implements "Gmail rules" by default for email address validation.
You can use .superRefine for custom behavior:
.superRefine
const emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+-\.]*)[A-Z0-9_'+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i; const emailSchema = z.string().superRefine((data, ctx) => { if (!emailRegex.test(data)) { ctx.addIssue({ code: z.ZodIssueCode.invalid_string, message: "Invalid email address", validation: "email", }); } });
No branches or pull requests
Hi there,
I noticed the z.string().email() fails when the email contains an ampersand sign. This should be allowed.
Example:
z.string().email().parse("test&[email protected]")
The text was updated successfully, but these errors were encountered: