mirror of
https://github.com/egulias/EmailValidator.git
synced 2026-09-01 13:08:58 +00:00
Consecutive AT
This commit is contained in:
@@ -11,7 +11,6 @@ use Egulias\EmailValidator\InvalidEmail;
|
||||
*/
|
||||
class EmailValidator
|
||||
{
|
||||
const ERR_CONSECUTIVEATS = 128;
|
||||
const ERR_EXPECTING_DTEXT = 129;
|
||||
const ERR_NOLOCALPART = 130;
|
||||
const ERR_NODOMAIN = 131;
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
use Egulias\EmailValidator\InvalidEmail;
|
||||
|
||||
class ConsecutiveAt extends InvalidEmail
|
||||
{
|
||||
const CODE = 128;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct("Consecutive AT", self::CODE);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
namespace Egulias\EmailValidator\Parser;
|
||||
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\Exception\ConsecutiveAt;
|
||||
use Egulias\EmailValidator\Exception\DotAtStart;
|
||||
use Egulias\EmailValidator\Parser\Parser;
|
||||
use Egulias\EmailValidator\EmailValidator;
|
||||
@@ -260,7 +261,7 @@ class DomainPart extends Parser
|
||||
}
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_AT) {
|
||||
throw new \InvalidArgumentException('ERR_CONSECUTIVEATS');
|
||||
throw new ConsecutiveAt();
|
||||
}
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_OPENQBRACKET && $prev['type'] !== EmailLexer::S_AT) {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Egulias\Tests\EmailValidator;
|
||||
|
||||
use Egulias\EmailValidator\EmailValidator;
|
||||
use Egulias\EmailValidator\Exception\ConsecutiveAt;
|
||||
use Egulias\EmailValidator\Exception\DotAtStart;
|
||||
|
||||
class EmailValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
@@ -144,7 +145,7 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
array(EmailValidator::ERR_NODOMAIN, 'example@'),
|
||||
array(EmailValidator::ERR_DOMAINHYPHENEND, 'example@example-.co.uk'),
|
||||
array(EmailValidator::ERR_DOMAINHYPHENEND, 'example@example-'),
|
||||
array(EmailValidator::ERR_CONSECUTIVEATS, 'example@@example.co.uk'),
|
||||
array(ConsecutiveAt::CODE, 'example@@example.co.uk'),
|
||||
array(EmailValidator::ERR_CONSECUTIVEDOTS, 'example..example@example.co.uk'),
|
||||
array(EmailValidator::ERR_CONSECUTIVEDOTS, 'example@example..co.uk'),
|
||||
array(EmailValidator::ERR_EXPECTING_ATEXT, '<fabien_potencier>@example.fr'),
|
||||
|
||||
Reference in New Issue
Block a user