Skip to content
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

Allow apostrophe in email validation #3218

Conversation

seanmacisaac
Copy link

Also add tests for apostrophe for both cases since the regex is different for the last character.

Not sure if the deno files are supposed to be checked in or not (since they are generated) but since they are also include them in this PR.

Fixes at least the most recent comments in #2396

Also add tests for apostrophe for both cases since
the regex is different for the last character.

Not sure if the deno files are supposed to be checked in
or not (since they are generated) but since they are also
include them in this PR.
Copy link

netlify bot commented Feb 6, 2024

Deploy Preview for guileless-rolypoly-866f8a ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 1dd08af
🔍 Latest deploy log https://app.netlify.com/sites/guileless-rolypoly-866f8a/deploys/65c2769938898d000745282e
😎 Deploy Preview https://deploy-preview-3218--guileless-rolypoly-866f8a.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@supervanya
Copy link

Would love for this to get merged as this is a need for one of our clients, what is needed for this to get merged?

@colinhacks
Copy link
Owner

colinhacks commented Feb 15, 2024

I'm not particularly interested in updating the email regex. #2157 represents a "final rule" on that question.

Zod implements the "gmail standard" now, which I think is the most useful and expected for the average (Latin-alphabet-using) developer. Everything else can use .regex() to customize. In Zod 4 I'm planning to export some common regexes from zod/regex to make it easier for users who are looking to validate against a particular RFC standard.

Apologies, there's no pleasing everyone here and imo this is the best tradeoff.

@emilbryggare
Copy link

Adding a solution that I used based on @colinhacks comment so other people can solve this if they find this issue. I modified the Zod email regexp from

const emailRegex =
to allow apostrophes.

 email: z
    .string()
    .regex(
      /^(?!\.)(?!.*\.\.)([A-Z0-9_'+-\.]*)[A-Z0-9_'+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,
      'Invalid email',
    ),

@colinhacks
Copy link
Owner

colinhacks commented Apr 16, 2024

[Update] It appears single quotes are specifically allowed by Google Workspace, just not by regular Gmail. That also appears to be virtually the only difference between the two. So I'm happy to merge this.

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.

4 participants