-
Notifications
You must be signed in to change notification settings - Fork 35
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
Use different E-Mail regex #59
base: master
Are you sure you want to change the base?
Conversation
As noted in valiktor#57, the current Regex is broken for Emails like: ``` foo.bar+mysuffix@gmail.com ``` Therefore, exchange the used regex with the one from emailregex.com.
@@ -479,7 +479,8 @@ fun <E> Validator<E>.Property<String?>.doesNotEndWithIgnoringCase(suffix: String | |||
fun <E> Validator<E>.Property<String?>.isEmail(): Validator<E>.Property<String?> = | |||
this.validate(Email) { | |||
it == null || it.matches( | |||
Regex("^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$") | |||
// see https://emailregex.com/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we dont need to keep this comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the comment is pretty important, because it's easier to go to emailregex.com
and read the documentation of the Regex instead of trying to figure out if the given regex makes sense 😉
@@ -479,7 +479,8 @@ fun <E> Validator<E>.Property<String?>.doesNotEndWithIgnoringCase(suffix: String | |||
fun <E> Validator<E>.Property<String?>.isEmail(): Validator<E>.Property<String?> = | |||
this.validate(Email) { | |||
it == null || it.matches( | |||
Regex("^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$") | |||
// see https://emailregex.com/ | |||
Regex("""(?:[a-z0-9!#${'$'}%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#${'$'}%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])""") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
${'$'}
is this necessary? cant we just scape the $
character?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure anymore, this pr is already pretty old and to be honest we have moved on and I don't care too much about this anymore
As noted in #57, the current Regex is broken for Emails like:
Therefore, exchange the used regex with the one from emailregex.com.