Skip to content

Commit 2a614c5

Browse files
authored
Add support to validate unicode email. (#326)
1 parent f3b53eb commit 2a614c5

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/Assert.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ public static function email(mixed $value, string $message = ''): string
801801
{
802802
static::string($value);
803803

804-
if (false === \filter_var($value, FILTER_VALIDATE_EMAIL)) {
804+
if (false === \filter_var($value, FILTER_VALIDATE_EMAIL, FILTER_FLAG_EMAIL_UNICODE)) {
805805
static::reportInvalidArgument(\sprintf(
806806
$message ?: 'Expected a value to be a valid e-mail address. Got: %s',
807807
static::valueToString($value)

tests/AssertTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,7 @@ public static function getTests(): array
597597
array('email', array(123), false),
598598
array('email', array('foo.com'), false),
599599
array('email', array('[email protected]'), true),
600+
array('email', array('föö@bar.com'), true),
600601
array('uniqueValues', array(array('qwerty', 'qwerty')), false),
601602
array('uniqueValues', array(array('asdfg', 'qwerty')), true),
602603
array('uniqueValues', array(array(123, '123')), false),

0 commit comments

Comments
 (0)