Skip to content

Commit

Permalink
Merge pull request #15 from nymo/improve-email-regexp
Browse files Browse the repository at this point in the history
Improve email validation for domain part
  • Loading branch information
naucon authored Sep 4, 2023
2 parents 8a09cdd + a4cc450 commit 1bcf9c2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Validator/Constraints/IsEmailValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
class IsEmailValidator extends ConstraintValidator
{
const REGEXP = '/^(?![.-])([a-zA-Z0-9_\-\+]+(?:\.[a-zA-Z0-9_\-\+]+)*\@([a-zA-Z0-9\-\+]+\.?)+[a-zA-Z0-9]{0,10},?)+$/D';
const REGEXP = '/^(?![.-])([a-zA-Z0-9_\-\+]+(\.[a-zA-Z0-9_\-\+]+)*)@([a-zA-Z0-9]+([\-\.]{1}[a-zA-Z0-9]+)*)\.([a-zA-Z0-9]{2,10})$/D';

/**
* {@inheritdoc}
Expand Down
7 changes: 6 additions & 1 deletion tests/Validator/Constraints/IsEmailValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function valueProvider()
['[email protected]', true],
['[email protected]', true],
['[email protected]', true],
['admin@mailserver1', true],
['admin@mailserver1', false], //invalid domain name
['[email protected]', true],
['[email protected]', true],
['[[email protected]]', false],
Expand Down Expand Up @@ -65,6 +65,11 @@ public function valueProvider()
['abc', false],
['', false],
[null, true],
['[email protected]', false],
['[email protected]', false],
['olaf@t-onlinde', false],
['[email protected]', false],
['olav@gmail', false],
];
}

Expand Down

0 comments on commit 1bcf9c2

Please sign in to comment.