Compare commits

..

3 Commits

Author SHA1 Message Date
Eduardo Gulias Davis af864423f5 Composer udpates 2015-06-22 23:07:51 +02:00
Eduardo Gulias Davis 12f16f70aa Merge pull request #70 from cilefen/master
Replaces dos-type line endings. Fixes issue #69.
2015-05-18 23:32:19 +02:00
Chris McCafferty 0afaa6a3b6 Replaces dos-type line endings. Fixes issue #69. 2015-05-17 16:37:57 -04:00
5 changed files with 603 additions and 486 deletions
+59 -59
View File
@@ -1,59 +1,59 @@
#EmailValidator #EmailValidator
[![Build Status](https://travis-ci.org/egulias/EmailValidator.png?branch=master)](https://travis-ci.org/egulias/EmailValidator) [![Coverage Status](https://coveralls.io/repos/egulias/EmailValidator/badge.png?branch=master)](https://coveralls.io/r/egulias/EmailValidator?branch=master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/egulias/EmailValidator/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/egulias/EmailValidator/?branch=master) [![SensioLabsInsight](https://insight.sensiolabs.com/projects/22ba6692-9c02-42e5-a65d-1c5696bfffc6/small.png)](https://insight.sensiolabs.com/projects/22ba6692-9c02-42e5-a65d-1c5696bfffc6) [![Build Status](https://travis-ci.org/egulias/EmailValidator.png?branch=master)](https://travis-ci.org/egulias/EmailValidator) [![Coverage Status](https://coveralls.io/repos/egulias/EmailValidator/badge.png?branch=master)](https://coveralls.io/r/egulias/EmailValidator?branch=master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/egulias/EmailValidator/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/egulias/EmailValidator/?branch=master) [![SensioLabsInsight](https://insight.sensiolabs.com/projects/22ba6692-9c02-42e5-a65d-1c5696bfffc6/small.png)](https://insight.sensiolabs.com/projects/22ba6692-9c02-42e5-a65d-1c5696bfffc6)
============================= =============================
With the help of With the help of
![Powered by PhpStorm](https://www.jetbrains.com/phpstorm/documentation/docs/logo_phpstorm.png) ![Powered by PhpStorm](https://www.jetbrains.com/phpstorm/documentation/docs/logo_phpstorm.png)
##Installation## ##Installation##
Run the command below to install via Composer Run the command below to install via Composer
```shell ```shell
composer require egulias/email-validator composer require egulias/email-validator
``` ```
##Usage## ##Usage##
Simple example: Simple example:
```php ```php
<?php <?php
use Egulias\EmailValidator\EmailValidator; use Egulias\EmailValidator\EmailValidator;
$validator = new EmailValidator; $validator = new EmailValidator;
if ($validator->isValid($email)) { if ($validator->isValid($email)) {
echo $email . ' is a valid email address'; echo $email . ' is a valid email address';
} }
``` ```
More advanced example (returns detailed diagnostic error codes): More advanced example (returns detailed diagnostic error codes):
```php ```php
<?php <?php
use Egulias\EmailValidator\EmailValidator; use Egulias\EmailValidator\EmailValidator;
$validator = new EmailValidator; $validator = new EmailValidator;
$email = 'dominic@sayers.cc'; $email = 'dominic@sayers.cc';
$result = $validator->isValid($email); $result = $validator->isValid($email);
if ($result) { if ($result) {
echo $email . ' is a valid email address'; echo $email . ' is a valid email address';
} else if ($validator->hasWarnings()) { } else if ($validator->hasWarnings()) {
echo 'Warning! ' . $email . ' has unusual/deprecated features (result code ' . var_export($validator->getWarnings(), true) . ')'; echo 'Warning! ' . $email . ' has unusual/deprecated features (result code ' . var_export($validator->getWarnings(), true) . ')';
} else { } else {
echo $email . ' is not a valid email address (result code ' . $validator->getError() . ')'; echo $email . ' is not a valid email address (result code ' . $validator->getError() . ')';
} }
``` ```
##Contributors## ##Contributors##
As this is a port from another library and work, here are other people related to the previous: As this is a port from another library and work, here are other people related to the previous:
* Ricard Clau [@ricardclau](http://github.com/ricardclau): Performance against PHP built-in filter_var * Ricard Clau [@ricardclau](http://github.com/ricardclau): Performance against PHP built-in filter_var
* Josepf Bielawski [@stloyd](http://github.com/stloyd): For its first re-work of Dominic's lib * Josepf Bielawski [@stloyd](http://github.com/stloyd): For its first re-work of Dominic's lib
* Dominic Sayers [@dominicsayers](http://github.com/dominicsayers): The original isemail function * Dominic Sayers [@dominicsayers](http://github.com/dominicsayers): The original isemail function
##License## ##License##
Released under the MIT License attached with this code. Released under the MIT License attached with this code.
+2 -2
View File
@@ -3,14 +3,14 @@
"description": "A library for validating emails", "description": "A library for validating emails",
"homepage": "https://github.com/egulias/EmailValidator", "homepage": "https://github.com/egulias/EmailValidator",
"type": "Library", "type": "Library",
"keywords": ["email", "validation", "validator"], "keywords": ["email", "validation", "validator", "emailvalidation", "emailvalidator"],
"license": "MIT", "license": "MIT",
"authors": [ "authors": [
{"name": "Eduardo Gulias Davis"} {"name": "Eduardo Gulias Davis"}
], ],
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.3.x-dev" "dev-master": "2.0.x-dev"
} }
}, },
"require": { "require": {
Generated
+312 -195
View File
File diff suppressed because it is too large Load Diff
+89 -89
View File
@@ -1,89 +1,89 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>The BNF from RFC 5321 defining parts of a valid SMTP address</title> <title>The BNF from RFC 5321 defining parts of a valid SMTP address</title>
</head> </head>
<body> <body>
<pre style="font-size:11px;"> <pre style="font-size:11px;">
Mailbox = Local-part "@" ( Domain / address-literal ) Mailbox = Local-part "@" ( Domain / address-literal )
Local-part = Dot-string / Quoted-string Local-part = Dot-string / Quoted-string
; MAY be case-sensitive ; MAY be case-sensitive
Dot-string = Atom *("." Atom) Dot-string = Atom *("." Atom)
Atom = 1*atext Atom = 1*atext
Quoted-string = DQUOTE *QcontentSMTP DQUOTE Quoted-string = DQUOTE *QcontentSMTP DQUOTE
QcontentSMTP = qtextSMTP / quoted-pairSMTP QcontentSMTP = qtextSMTP / quoted-pairSMTP
quoted-pairSMTP = %d92 %d32-126 quoted-pairSMTP = %d92 %d32-126
; i.e., backslash followed by any ASCII ; i.e., backslash followed by any ASCII
; graphic (including itself) or SPace ; graphic (including itself) or SPace
qtextSMTP = %d32-33 / %d35-91 / %d93-126 qtextSMTP = %d32-33 / %d35-91 / %d93-126
; i.e., within a quoted string, any ; i.e., within a quoted string, any
; ASCII graphic or space is permitted ; ASCII graphic or space is permitted
; without blackslash-quoting except ; without blackslash-quoting except
; double-quote and the backslash itself. ; double-quote and the backslash itself.
Domain = sub-domain *("." sub-domain) Domain = sub-domain *("." sub-domain)
sub-domain = Let-dig [Ldh-str] sub-domain = Let-dig [Ldh-str]
Let-dig = ALPHA / DIGIT Let-dig = ALPHA / DIGIT
Ldh-str = *( ALPHA / DIGIT / "-" ) Let-dig Ldh-str = *( ALPHA / DIGIT / "-" ) Let-dig
address-literal = "[" ( IPv4-address-literal / address-literal = "[" ( IPv4-address-literal /
IPv6-address-literal / IPv6-address-literal /
General-address-literal ) "]" General-address-literal ) "]"
; See Section 4.1.3 ; See Section 4.1.3
IPv4-address-literal = Snum 3("." Snum) IPv4-address-literal = Snum 3("." Snum)
IPv6-address-literal = "IPv6:" IPv6-addr IPv6-address-literal = "IPv6:" IPv6-addr
General-address-literal = Standardized-tag ":" 1*dcontent General-address-literal = Standardized-tag ":" 1*dcontent
Standardized-tag = Ldh-str Standardized-tag = Ldh-str
; Standardized-tag MUST be specified in a ; Standardized-tag MUST be specified in a
; Standards-Track RFC and registered with IANA ; Standards-Track RFC and registered with IANA
dcontent = %d33-90 / ; Printable US-ASCII dcontent = %d33-90 / ; Printable US-ASCII
%d94-126 ; excl. "[", "\", "]" %d94-126 ; excl. "[", "\", "]"
Snum = 1*3DIGIT Snum = 1*3DIGIT
; representing a decimal integer ; representing a decimal integer
; value in the range 0 through 255 ; value in the range 0 through 255
IPv6-addr = IPv6-full / IPv6-comp / IPv6v4-full / IPv6v4-comp IPv6-addr = IPv6-full / IPv6-comp / IPv6v4-full / IPv6v4-comp
IPv6-hex = 1*4HEXDIG IPv6-hex = 1*4HEXDIG
IPv6-full = IPv6-hex 7(":" IPv6-hex) IPv6-full = IPv6-hex 7(":" IPv6-hex)
IPv6-comp = [IPv6-hex *5(":" IPv6-hex)] "::" IPv6-comp = [IPv6-hex *5(":" IPv6-hex)] "::"
[IPv6-hex *5(":" IPv6-hex)] [IPv6-hex *5(":" IPv6-hex)]
; The "::" represents at least 2 16-bit groups of ; The "::" represents at least 2 16-bit groups of
; zeros. No more than 6 groups in addition to the ; zeros. No more than 6 groups in addition to the
; "::" may be present. ; "::" may be present.
IPv6v4-full = IPv6-hex 5(":" IPv6-hex) ":" IPv4-address-literal IPv6v4-full = IPv6-hex 5(":" IPv6-hex) ":" IPv4-address-literal
IPv6v4-comp = [IPv6-hex *3(":" IPv6-hex)] "::" IPv6v4-comp = [IPv6-hex *3(":" IPv6-hex)] "::"
[IPv6-hex *3(":" IPv6-hex) ":"] [IPv6-hex *3(":" IPv6-hex) ":"]
IPv4-address-literal IPv4-address-literal
; The "::" represents at least 2 16-bit groups of ; The "::" represents at least 2 16-bit groups of
; zeros. No more than 4 groups in addition to the ; zeros. No more than 4 groups in addition to the
; "::" and IPv4-address-literal may be present. ; "::" and IPv4-address-literal may be present.
</pre> </pre>
</body> </body>
</html> </html>
+141 -141
View File
@@ -1,141 +1,141 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>The BNF from RFC 5322 defining parts of a valid internet message address</title> <title>The BNF from RFC 5322 defining parts of a valid internet message address</title>
</head> </head>
<body> <body>
<pre style="font-size:11px;"> <pre style="font-size:11px;">
addr-spec = local-part "@" domain addr-spec = local-part "@" domain
local-part = dot-atom / quoted-string / obs-local-part local-part = dot-atom / quoted-string / obs-local-part
dot-atom = [CFWS] dot-atom-text [CFWS] dot-atom = [CFWS] dot-atom-text [CFWS]
CFWS = (1*([FWS] comment) [FWS]) / FWS CFWS = (1*([FWS] comment) [FWS]) / FWS
FWS = ([*WSP CRLF] 1*WSP) / obs-FWS FWS = ([*WSP CRLF] 1*WSP) / obs-FWS
; Folding white space ; Folding white space
WSP = SP / HTAB ; white space WSP = SP / HTAB ; white space
obs-FWS = 1*([CRLF] WSP) ; As amended in erratum #1908 obs-FWS = 1*([CRLF] WSP) ; As amended in erratum #1908
ctext = %d33-39 / ; Printable US-ASCII ctext = %d33-39 / ; Printable US-ASCII
%d42-91 / ; characters not including %d42-91 / ; characters not including
%d93-126 / ; "(", ")", or "\" %d93-126 / ; "(", ")", or "\"
obs-ctext obs-ctext
obs-ctext = obs-NO-WS-CTL obs-ctext = obs-NO-WS-CTL
ccontent = ctext / quoted-pair / comment ccontent = ctext / quoted-pair / comment
comment = "(" *([FWS] ccontent) [FWS] ")" comment = "(" *([FWS] ccontent) [FWS] ")"
dot-atom-text = 1*atext *("." 1*atext) dot-atom-text = 1*atext *("." 1*atext)
atext = ALPHA / DIGIT / ; Printable US-ASCII atext = ALPHA / DIGIT / ; Printable US-ASCII
"!" / "#" / ; characters not including "!" / "#" / ; characters not including
"$" / "%" / ; specials. Used for atoms. "$" / "%" / ; specials. Used for atoms.
"&amp;" / "'" / "&amp;" / "'" /
"*" / "+" / "*" / "+" /
"-" / "/" / "-" / "/" /
"=" / "?" / "=" / "?" /
"^" / "_" / "^" / "_" /
"`" / "{" / "`" / "{" /
"|" / "}" / "|" / "}" /
"~" "~"
specials = "(" / ")" / ; Special characters that do specials = "(" / ")" / ; Special characters that do
"&lt;" / "&gt;" / ; not appear in atext "&lt;" / "&gt;" / ; not appear in atext
"[" / "]" / "[" / "]" /
":" / ";" / ":" / ";" /
"@" / "\" / "@" / "\" /
"," / "." / "," / "." /
DQUOTE DQUOTE
quoted-string = [CFWS] quoted-string = [CFWS]
DQUOTE *([FWS] qcontent) [FWS] DQUOTE DQUOTE *([FWS] qcontent) [FWS] DQUOTE
[CFWS] [CFWS]
qcontent = qtext / quoted-pair qcontent = qtext / quoted-pair
qtext = %d33 / ; Printable US-ASCII qtext = %d33 / ; Printable US-ASCII
%d35-91 / ; characters not including %d35-91 / ; characters not including
%d93-126 / ; "\" or the quote character %d93-126 / ; "\" or the quote character
obs-qtext obs-qtext
obs-qtext = obs-NO-WS-CTL obs-qtext = obs-NO-WS-CTL
obs-NO-WS-CTL = %d1-8 / ; US-ASCII control obs-NO-WS-CTL = %d1-8 / ; US-ASCII control
%d11 / ; characters that do not %d11 / ; characters that do not
%d12 / ; include the carriage %d12 / ; include the carriage
%d14-31 / ; return, line feed, and %d14-31 / ; return, line feed, and
%d127 ; white space characters %d127 ; white space characters
quoted-pair = ("\" (VCHAR / WSP)) / obs-qp quoted-pair = ("\" (VCHAR / WSP)) / obs-qp
VCHAR = %x21-7E ; visible (printing) characters VCHAR = %x21-7E ; visible (printing) characters
obs-qp = "\" (%d0 / obs-NO-WS-CTL / LF / CR) obs-qp = "\" (%d0 / obs-NO-WS-CTL / LF / CR)
obs-local-part = word *("." word) obs-local-part = word *("." word)
word = atom / quoted-string word = atom / quoted-string
atom = [CFWS] 1*atext [CFWS] atom = [CFWS] 1*atext [CFWS]
domain = dot-atom / domain-literal / obs-domain domain = dot-atom / domain-literal / obs-domain
domain-literal = [CFWS] "[" *([FWS] dtext) [FWS] "]" [CFWS] domain-literal = [CFWS] "[" *([FWS] dtext) [FWS] "]" [CFWS]
dtext = %d33-90 / ; Printable US-ASCII dtext = %d33-90 / ; Printable US-ASCII
%d94-126 / ; characters not including %d94-126 / ; characters not including
obs-dtext ; "[", "]", or "\" obs-dtext ; "[", "]", or "\"
obs-dtext = obs-NO-WS-CTL / quoted-pair obs-dtext = obs-NO-WS-CTL / quoted-pair
obs-domain = atom *("." atom) obs-domain = atom *("." atom)
NB For SMTP mail, the domain-literal is restricted by RFC5321 as follows: NB For SMTP mail, the domain-literal is restricted by RFC5321 as follows:
Mailbox = Local-part "@" ( Domain / address-literal ) Mailbox = Local-part "@" ( Domain / address-literal )
address-literal = "[" ( IPv4-address-literal / address-literal = "[" ( IPv4-address-literal /
IPv6-address-literal / IPv6-address-literal /
General-address-literal ) "]" General-address-literal ) "]"
IPv4-address-literal = Snum 3("." Snum) IPv4-address-literal = Snum 3("." Snum)
IPv6-address-literal = "IPv6:" IPv6-addr IPv6-address-literal = "IPv6:" IPv6-addr
Snum = 1*3DIGIT Snum = 1*3DIGIT
; representing a decimal integer ; representing a decimal integer
; value in the range 0 through 255 ; value in the range 0 through 255
IPv6-addr = IPv6-full / IPv6-comp / IPv6v4-full / IPv6v4-comp IPv6-addr = IPv6-full / IPv6-comp / IPv6v4-full / IPv6v4-comp
IPv6-hex = 1*4HEXDIG IPv6-hex = 1*4HEXDIG
IPv6-full = IPv6-hex 7(":" IPv6-hex) IPv6-full = IPv6-hex 7(":" IPv6-hex)
IPv6-comp = [IPv6-hex *5(":" IPv6-hex)] "::" IPv6-comp = [IPv6-hex *5(":" IPv6-hex)] "::"
[IPv6-hex *5(":" IPv6-hex)] [IPv6-hex *5(":" IPv6-hex)]
; The "::" represents at least 2 16-bit groups of ; The "::" represents at least 2 16-bit groups of
; zeros. No more than 6 groups in addition to the ; zeros. No more than 6 groups in addition to the
; "::" may be present. ; "::" may be present.
IPv6v4-full = IPv6-hex 5(":" IPv6-hex) ":" IPv4-address-literal IPv6v4-full = IPv6-hex 5(":" IPv6-hex) ":" IPv4-address-literal
IPv6v4-comp = [IPv6-hex *3(":" IPv6-hex)] "::" IPv6v4-comp = [IPv6-hex *3(":" IPv6-hex)] "::"
[IPv6-hex *3(":" IPv6-hex) ":"] [IPv6-hex *3(":" IPv6-hex) ":"]
IPv4-address-literal IPv4-address-literal
; The "::" represents at least 2 16-bit groups of ; The "::" represents at least 2 16-bit groups of
; zeros. No more than 4 groups in addition to the ; zeros. No more than 4 groups in addition to the
; "::" and IPv4-address-literal may be present. ; "::" and IPv4-address-literal may be present.
</pre> </pre>
</body> </body>
</html> </html>