diff --git a/src/Illuminate/Validation/Concerns/FilterEmailValidation.php b/src/Illuminate/Validation/Concerns/FilterEmailValidation.php new file mode 100644 index 000000000000..cc38acead0cc --- /dev/null +++ b/src/Illuminate/Validation/Concerns/FilterEmailValidation.php @@ -0,0 +1,43 @@ +isValid($value, new RFCValidation); + $validations = collect($parameters) + ->unique() + ->map(function ($validation) { + if ($validation === 'rfc') { + return new RFCValidation(); + } elseif ($validation === 'strict') { + return new NoRFCWarningsValidation(); + } elseif ($validation === 'dns') { + return new DNSCheckValidation(); + } elseif ($validation === 'spoof') { + return new SpoofCheckValidation(); + } elseif ($validation === 'filter') { + return new FilterEmailValidation(); + } + }) + ->values() + ->all() ?: [new RFCValidation()]; + + return (new EmailValidator)->isValid($value, new MultipleValidationWithAnd($validations)); } /** diff --git a/tests/Validation/ValidationValidatorTest.php b/tests/Validation/ValidationValidatorTest.php index 3db1e06c0c0a..7a2866cb74b7 100755 --- a/tests/Validation/ValidationValidatorTest.php +++ b/tests/Validation/ValidationValidatorTest.php @@ -2138,6 +2138,18 @@ public function testValidateEmailWithInternationalCharacters() $this->assertTrue($v->passes()); } + public function testValidateEmailWithStrictCheck() + { + $v = new Validator($this->getIlluminateArrayTranslator(), ['x' => 'foo@bar '], ['x' => 'email:strict']); + $this->assertFalse($v->passes()); + } + + public function testValidateEmailWithFilterCheck() + { + $v = new Validator($this->getIlluminateArrayTranslator(), ['x' => 'foo@bar'], ['x' => 'email:filter']); + $this->assertFalse($v->passes()); + } + /** * @dataProvider validUrls */