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

fix(type): require tld for email addresses #558

Closed
wants to merge 1 commit into from

Conversation

fergusean
Copy link
Contributor

Summary of changes

I had some users enter someuser@gmail as their email. The validator accepted it, but then Stripe threw when trying to create their customer profile since gmail isn't a valid FQDN.

Relinquishment of Rights

Please mark following checkbox to confirm that you relinquish all rights of your changes:

  • I waive and relinquish all rights regarding this changes (including code, text, and images) to Deepkit UG (limited), Germany. This changes (including code, text, and images) are under MIT license without name attribution, copyright notice, and permission notice requirement.

@codecov-commenter
Copy link

codecov-commenter commented Mar 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.59%. Comparing base (eb92e58) to head (6e40ad8).

❗ Current head 6e40ad8 differs from pull request most recent head f80c53a. Consider uploading reports for the commit f80c53a to get more accurate results

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #558      +/-   ##
==========================================
+ Coverage   78.56%   78.59%   +0.02%     
==========================================
  Files         191      191              
  Lines       20412    20412              
  Branches     5300     5300              
==========================================
+ Hits        16036    16042       +6     
+ Misses       4376     4370       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@marcj
Copy link
Member

marcj commented Mar 11, 2024

the problem is that an email like marc@localhost is a valid email, so we can not enforce a tld. Also making a "proper general purpose" email validation is quite hard https://stackoverflow.com/questions/201323/how-can-i-validate-an-email-address-using-a-regular-expression, so I decided to go with the most simples solution, and people should write their own Email type if needed.

export const EMAIL_REGEX = /^\S+@\S+\.\S+$/;
export type MyEmail = string & Pattern<typeof EMAIL_REGEX>;

@fergusean
Copy link
Contributor Author

ok fair enough :)

@fergusean fergusean closed this Mar 11, 2024
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.

3 participants