email-validator-pro
v1.0.1
Published
Validate email address patterns that others don't. This project aims to support all common addresses along with many rare ones that are considered valid under RFC standards. It can be used in both client and server side environments.
Downloads
37
Maintainers
Readme
EmailValidatorPro
Support valid email address patterns that others don't (including unicode characters, IP address domains, quoted local parts, et al.).
Many validators — including the one that's baked into HTML5 — only support more common email addresses. This project aims to support all common addresses along with many rare ones that are considered valid under RFC standards. It works on both client and server side environments.
See the email address wiki page for more details on acceptable addresses. See some valid address examples below.
Usage
Node
npm i email-validator-pro -S
let EmailValidatorPro = require("email-validator-pro");
Minified version:
let EmailValidatorPro = require("email-validator-pro/dist/EmailValidatorPro.min");
Browser
import EmailValidatorPro from "email-validator-pro";
Minified version:
import EmailValidatorPro from "email-validator-pro/dist/EmailValidatorPro.min";
Script tag:
<script src="node_modules/email-validator-pro/dist/EmailValidatorPro.min.js"></script>
Notes
- This project is dependency free.
- The source code is written in ES6 and transpiled with Babel.
- If you need to create documentation for local use, run
npm run doc
. Otherwise, visit the online docs. - Some rare, but RFC compliant email addresses are not supported.
- See the unit test lines labeled "Valid, but unsupported..." .
- Pull requests are welcomed.
Samples
let evp = new EmailValidatorPro();
console.log(evp.isValidAddress("[email protected]")); //true
console.log(evp.isValidAddress("[email protected]")); //false
let evp = new EmailValidatorPro(),
parts = evp.getParts("[email protected]");
console.log(parts); //{local: "contact", domain: "email.com"}
See the full documentation.
Valid Addresses
Patterns like the below are RFC compliant and supported.
niceandsimple
@example.com
very.common
@example.com
a.little.lengthy.but.fine
@dept.example.com
disposable.style.email.with+symbol
@example.com
other.email-with-dash
@example.com
"much.more unusual"
@example.com
"[email protected]"
@example.com
#!$%&\'*+-/=?^_{}|~
@example.org
" "
@example.org
üñîçøðé
@üñîçøðé.com
admin
@mailserver1
user
@tt
"hi"
@example.com
jsmith
@[192.168.2.1]
jsmith
@[IPv6:2001:db8::1]
email
@123.123.123.123
"()<>[]:,;@\\\"!#$%&\'*+-/=?^_{}| ~.a"
@example.org
abc."defghi".xyz
@example.com
_______
@example.com
very.unusual."@".unusual.com
@example.com
john.smith(comment)
@example.com
(comment)john.smith
@example.com
"()<>[]:,;@\\\"!#$%&\'*+-/=?^_{}| ~.a"(comment)
@example.org
Valid, But Unsupported Addresses
The below are valid (but rare) email addresses that are not supported.
"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"
@strange.example.com
"()<>[]:,;@\"!#$%&\'*+-/=?^_{}| ~.a"
@example.org
abc."d\"efghi".xyz
@example.com
much."more\ unusual"
@example.com
Unit Tests
See the unit tests.
License
Copyright (c) 2012, 2017 Leandro Silva (http://grafluxe.com)
Released under the MIT License.
See LICENSE.md for entire terms.