Skip to content

Commit

Permalink
Use a library for email validation
Browse files Browse the repository at this point in the history
  • Loading branch information
phroggyy committed Nov 13, 2018
1 parent f737c23 commit 0fd6ca1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"ext-openssl": "*",
"doctrine/inflector": "^1.1",
"dragonmantank/cron-expression": "^2.0",
"egulias/email-validator": "~2.0",
"erusev/parsedown": "^1.7",
"league/flysystem": "^1.0.8",
"monolog/monolog": "^1.12",
Expand Down
4 changes: 3 additions & 1 deletion src/Illuminate/Validation/Concerns/ValidatesAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
use Illuminate\Validation\Rules\Exists;
use Illuminate\Validation\Rules\Unique;
use Illuminate\Validation\ValidationData;
use Egulias\EmailValidator\EmailValidator;
use Symfony\Component\HttpFoundation\File\File;
use Egulias\EmailValidator\Validation\RFCValidation;
use Symfony\Component\HttpFoundation\File\UploadedFile;

trait ValidatesAttributes
Expand Down Expand Up @@ -590,7 +592,7 @@ public function validateDistinct($attribute, $value, $parameters)
*/
public function validateEmail($attribute, $value)
{
return filter_var($value, FILTER_VALIDATE_EMAIL) !== false;
return (new EmailValidator)->isValid($value, new RFCValidation);
}

/**
Expand Down
6 changes: 6 additions & 0 deletions tests/Validation/ValidationValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1969,6 +1969,12 @@ public function testValidateEmail()
$this->assertTrue($v->passes());
}

public function testValidateEmailWithInternationalCharacters()
{
$v = new Validator($this->getIlluminateArrayTranslator(), ['x' => 'foo@gmäil.com'], ['x' => 'email']);
$this->assertTrue($v->passes());
}

/**
* @dataProvider validUrls
*/
Expand Down

0 comments on commit 0fd6ca1

Please sign in to comment.