mirror of
https://github.com/egulias/EmailValidator.git
synced 2026-09-02 13:41:55 +00:00
Port of comma in domain and README improvement.
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
# EmailValidator
|
||||
[!https://img.shields.io/packagist/v/egulias/email-validator.svg?style=flat-square](https://packagist.org/packages/egulias/email-validator)
|
||||
|
||||
[](https://travis-ci.org/egulias/EmailValidator)
|
||||
[](https://coveralls.io/r/egulias/EmailValidator?branch=master)
|
||||
[](https://scrutinizer-ci.com/g/egulias/EmailValidator/?branch=master)
|
||||
[](https://insight.sensiolabs.com/projects/22ba6692-9c02-42e5-a65d-1c5696bfffc6)
|
||||
|
||||
## Suported RFCs ##
|
||||
## Supported RFCs ##
|
||||
|
||||
This library aims to support:
|
||||
|
||||
@@ -42,16 +42,14 @@ $validator->isValid("example@example.com", new RFCValidation()); //true
|
||||
|
||||
### Available validations ###
|
||||
|
||||
1. [RFCValidation](/src/Validation/RFCValidation.php)
|
||||
2. [NoRFCWarningsValidation](/src/Validation/NoRFCWarningsValidation.php)
|
||||
3. [DNSCheckValidation](/src/Validation/DNSCheckValidation.php)
|
||||
4. [SpoofCheckValidation](/src/Validation/SpoofCheckValidation.php)
|
||||
5. [MultipleValidationWithAnd](/src/Validation/MultipleValidationWithAnd.php)
|
||||
6. [Your own validation](#how-to-extend)
|
||||
1. [RFCValidation](/src/Validation/RFCValidation.php): Standard RFC-like email validation.
|
||||
2. [NoRFCWarningsValidation](/src/Validation/NoRFCWarningsValidation.php): RFC-like validation that will fail when warnings* are found.
|
||||
3. [DNSCheckValidation](/src/Validation/DNSCheckValidation.php): Will check if there are DNS records that signal that the server accepts emails. This does not entails that the email exists.
|
||||
4. [SpoofCheckValidation](/src/Validation/SpoofCheckValidation.php): Will check for multi-utf-8 chars that can signal an erroneous email name.
|
||||
5. [MultipleValidationWithAnd](/src/Validation/MultipleValidationWithAnd.php): It is a validation that operates over other validations performing a logical and (&&) over the result of each validation.
|
||||
6. [Your own validation](#how-to-extend): You can extend the library behaviour by implementing your own validations.
|
||||
|
||||
`MultipleValidationWithAnd`
|
||||
|
||||
It is a validation that operates over other validations performing a logical and (&&) over the result of each validation.
|
||||
*warnings: Warnings are deviations from the RFC that in a broader interpretation are acceptded.
|
||||
|
||||
```php
|
||||
<?php
|
||||
@@ -66,7 +64,8 @@ $multipleValidations = new MultipleValidationWithAnd([
|
||||
new RFCValidation(),
|
||||
new DNSCheckValidation()
|
||||
]);
|
||||
$validator->isValid("example@example.com", $multipleValidations); //true
|
||||
//ietf.org has MX records signaling a server with email capabilites
|
||||
$validator->isValid("example@ietf.org", $multipleValidations); //true
|
||||
```
|
||||
|
||||
### How to extend ###
|
||||
@@ -86,4 +85,4 @@ As this is a port from another library and work, here are other people related t
|
||||
|
||||
## License ##
|
||||
|
||||
Released under the MIT License attached with this code.
|
||||
Released under the MIT License attached with this code.
|
||||
@@ -13,6 +13,7 @@ class EmailLexer extends AbstractLexer
|
||||
const S_BACKSLASH = 92;
|
||||
const S_DOT = 46;
|
||||
const S_DQUOTE = 34;
|
||||
const S_SQUOTE = 39;
|
||||
const S_OPENPARENTHESIS = 49;
|
||||
const S_CLOSEPARENTHESIS = 261;
|
||||
const S_OPENBRACKET = 262;
|
||||
@@ -58,6 +59,7 @@ class EmailLexer extends AbstractLexer
|
||||
'/' => self::S_SLASH,
|
||||
',' => self::S_COMMA,
|
||||
'.' => self::S_DOT,
|
||||
"'" => self::S_SQUOTE,
|
||||
'"' => self::S_DQUOTE,
|
||||
'-' => self::S_HYPHEN,
|
||||
'::' => self::S_DOUBLECOLON,
|
||||
|
||||
@@ -235,6 +235,7 @@ class DomainPart extends Parser
|
||||
{
|
||||
$invalidDomainTokens = array(
|
||||
EmailLexer::S_DQUOTE => true,
|
||||
EmailLexer::S_SQUOTE => true,
|
||||
EmailLexer::S_SEMICOLON => true,
|
||||
EmailLexer::S_GREATERTHAN => true,
|
||||
EmailLexer::S_LOWERTHAN => true,
|
||||
|
||||
@@ -138,6 +138,7 @@ class EmailLexerTests extends TestCase
|
||||
array(":", EmailLexer::S_COLON),
|
||||
array(".", EmailLexer::S_DOT),
|
||||
array("\"", EmailLexer::S_DQUOTE),
|
||||
array("'", EmailLexer::S_SQUOTE),
|
||||
array("-", EmailLexer::S_HYPHEN),
|
||||
array("\\", EmailLexer::S_BACKSLASH),
|
||||
array("/", EmailLexer::S_SLASH),
|
||||
|
||||
@@ -105,6 +105,8 @@ class RFCValidationTest extends TestCase
|
||||
['validipv6@[IPv6:2001:db8:1ff::a0b:dbd0]'],
|
||||
['validipv4@[127.0.0.0]'],
|
||||
['validipv4@127.0.0.0'],
|
||||
['withhyphen@domain-exam.com'],
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
@@ -185,6 +187,7 @@ class RFCValidationTest extends TestCase
|
||||
['test@foo;bar.com'],
|
||||
['test;123@foobar.com'],
|
||||
['test@example..com'],
|
||||
["test@examp'le.com"],
|
||||
['email.email@email."'],
|
||||
['test@email>'],
|
||||
['test@email<'],
|
||||
@@ -245,6 +248,7 @@ class RFCValidationTest extends TestCase
|
||||
[new InvalidEmail(new CRNoLF(), "["), "example@[\r]"],
|
||||
[new InvalidEmail(new CRNoLF(), "\r"), "exam\rple@example.co.uk"],
|
||||
[new InvalidEmail(new CommaInDomain(), ','), 'example@exam,ple.com'],
|
||||
[new InvalidEmail(new ExpectingATEXT('Invalid token in domain'), "'"), "test@example.com'"],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user