mirror of
https://github.com/egulias/EmailValidator.git
synced 2026-08-31 12:40:28 +00:00
fixed DNSCheckValidation bug (#115)
This commit is contained in:
committed by
Eduardo Gulias Davis
parent
e9c46eed92
commit
afde3d3874
@@ -28,7 +28,7 @@ class DNSCheckValidation implements EmailValidation
|
||||
// use the input to check DNS if we cannot extract something similar to a domain
|
||||
$host = $email;
|
||||
// Arguable pattern to extract the domain. Not aiming to validate the domain nor the email
|
||||
$pattern = "/^[a-z'0-9]+([._-][a-z'0-9]+)*@([a-z0-9]+([._-][a-z0-9]+)+)+$/";
|
||||
$pattern = "/^[a-z'0-9]+([+._-][a-z'0-9]+)*@([a-z0-9]+([._-][a-z0-9]+)+)+$/";
|
||||
if (preg_match($pattern, $email, $result)) {
|
||||
$host = $this->extractHost($result);
|
||||
}
|
||||
|
||||
@@ -9,10 +9,21 @@ use Egulias\EmailValidator\Warning\NoDNSMXRecord;
|
||||
|
||||
class DNSCheckValidationTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testValidDNS()
|
||||
public function validEmailsProvider()
|
||||
{
|
||||
return [
|
||||
["example@example.com"],
|
||||
["example+foo@example.com"],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider validEmailsProvider
|
||||
*/
|
||||
public function testValidDNS($validEmail)
|
||||
{
|
||||
$validation = new DNSCheckValidation();
|
||||
$this->assertTrue($validation->isValid("example@example.com", new EmailLexer()));
|
||||
$this->assertTrue($validation->isValid($validEmail, new EmailLexer()));
|
||||
}
|
||||
|
||||
public function testInvalidDNS()
|
||||
|
||||
Reference in New Issue
Block a user