Chore: Centralize email validation functionality#23816
Merged
sampaiodiego merged 3 commits intodevelopfrom Dec 20, 2021
Merged
Conversation
tassoevan
reviewed
Nov 29, 2021
lib/emailValidator.ts
Outdated
Comment on lines
+6
to
+11
| case 'basic': | ||
| return basicEmailRegex.test(email); | ||
| case 'rfc': | ||
| return rfcEmailRegex.test(email); | ||
| default: | ||
| return basicEmailRegex.test(email); |
Member
There was a problem hiding this comment.
Suggested change
| case 'basic': | |
| return basicEmailRegex.test(email); | |
| case 'rfc': | |
| return rfcEmailRegex.test(email); | |
| default: | |
| return basicEmailRegex.test(email); | |
| case 'rfc': | |
| return rfcEmailRegex.test(email); | |
| case 'basic': | |
| default: | |
| return basicEmailRegex.test(email); |
Member
Author
There was a problem hiding this comment.
I thought we had the no-fallthrough rule enabled 🤔
lib/emailValidator.ts
Outdated
| @@ -0,0 +1,13 @@ | |||
| export const validateEmail = (email: string, options: { style: string } = { style: 'basic' }): boolean => { | |||
| const basicEmailRegex = /^.+@.+$/; | |||
Member
There was a problem hiding this comment.
looking into some regex you modified to use this function I found this one interesting: [^@].*@[^@], it makes sure only a single @ is allowed.. wdyt? 👀
Member
Author
There was a problem hiding this comment.
Fair enough, let me do the change 👀
Member
Author
Member
There was a problem hiding this comment.
oopsie.. looks like I missread the regex 🙈
Member
There was a problem hiding this comment.
ok, this one 😬 ^[^@]+@[^@]+$
Member
Author
sampaiodiego
approved these changes
Dec 1, 2021
Member
|
Although I have approved it already, what about writing some unit tests for it? maybe we can have an agreement that all functions in |
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Proposed changes (including videos or screenshots)
Issue(s)
Steps to test or reproduce
Further comments