mirror of
https://github.com/egulias/EmailValidator.git
synced 2026-09-10 10:06:37 +00:00
No Domain Part
This commit is contained in:
@@ -11,7 +11,6 @@ use Egulias\EmailValidator\InvalidEmail;
|
||||
*/
|
||||
class EmailValidator
|
||||
{
|
||||
const ERR_NOLOCALPART = 130;
|
||||
const ERR_NODOMAIN = 131;
|
||||
const ERR_CONSECUTIVEDOTS = 132;
|
||||
const ERR_ATEXT_AFTER_CFWS = 133;
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
use Egulias\EmailValidator\InvalidEmail;
|
||||
|
||||
class NoDomainPart extends InvalidEmail
|
||||
{
|
||||
const CODE = 131;
|
||||
const REASON = "No Domain part";
|
||||
}
|
||||
@@ -7,6 +7,7 @@ use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\Exception\ConsecutiveAt;
|
||||
use Egulias\EmailValidator\Exception\DotAtStart;
|
||||
use Egulias\EmailValidator\Exception\ExpectingDTEXT;
|
||||
use Egulias\EmailValidator\Exception\NoDomainPart;
|
||||
use Egulias\EmailValidator\Parser\Parser;
|
||||
use Egulias\EmailValidator\EmailValidator;
|
||||
|
||||
@@ -24,7 +25,7 @@ class DomainPart extends Parser
|
||||
}
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_EMPTY) {
|
||||
throw new \InvalidArgumentException('ERR_NODOMAIN');
|
||||
throw new NoDomainPart();
|
||||
}
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN) {
|
||||
throw new \InvalidArgumentException('ERR_DOMAINHYPHENEND');
|
||||
|
||||
@@ -6,6 +6,7 @@ use Egulias\EmailValidator\EmailValidator;
|
||||
use Egulias\EmailValidator\Exception\ConsecutiveAt;
|
||||
use Egulias\EmailValidator\Exception\DotAtStart;
|
||||
use Egulias\EmailValidator\Exception\ExpectingDTEXT;
|
||||
use Egulias\EmailValidator\Exception\NoDomainPart;
|
||||
use Egulias\EmailValidator\Exception\NoLocalPart;
|
||||
|
||||
class EmailValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
@@ -144,7 +145,7 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
return array(
|
||||
array(NoLocalPart::CODE, '@example.co.uk'),
|
||||
array(EmailValidator::ERR_NODOMAIN, 'example@'),
|
||||
array(NoDomainPart::CODE, 'example@'),
|
||||
array(EmailValidator::ERR_DOMAINHYPHENEND, 'example@example-.co.uk'),
|
||||
array(EmailValidator::ERR_DOMAINHYPHENEND, 'example@example-'),
|
||||
array(ConsecutiveAt::CODE, 'example@@example.co.uk'),
|
||||
|
||||
Reference in New Issue
Block a user