Project rename
This commit is contained in:
+16
@@ -0,0 +1,16 @@
|
||||
language: node_js
|
||||
cache:
|
||||
directories:
|
||||
- ~/.npm
|
||||
notifications:
|
||||
email: false
|
||||
script:
|
||||
- npm run test
|
||||
node_js:
|
||||
- '9'
|
||||
- '8'
|
||||
- '6'
|
||||
- '4'
|
||||
branches:
|
||||
except:
|
||||
- /^v\d+\.\d+\.\d+$/
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
## Change Log
|
||||
|
||||
### 1.0.5 (2016/08/24)
|
||||
- [#12](https://github.com/Sembiance/email-validator/pull/12) Added async support
|
||||
|
||||
### 1.0.4 (2016/01/19)
|
||||
- [#8](https://github.com/Sembiance/email-validator/issues/8) 1-character top-level domain names no longer pass validation
|
||||
|
||||
### 1.0.3 (2015/08/17)
|
||||
- [#6](https://github.com/Sembiance/email-validator/pull/6) Add support for digit only domain names
|
||||
|
||||
### 1.0.2 (2015/06/30)
|
||||
- [#4](https://github.com/Sembiance/email-validator/issues/5) Validator no longer crashes when passed nothing
|
||||
|
||||
### 1.0.1 (2014/07/28)
|
||||
- [#3](https://github.com/Sembiance/email-validator/pull/3) Add support for backticks in email addresses
|
||||
|
||||
### 1.0.0 (2013/12/24)
|
||||
- Initial release
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
This is free and unencumbered software released into the public domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
distribute this software, either in source code form or as a compiled
|
||||
binary, for any purpose, commercial or non-commercial, and by any
|
||||
means.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors
|
||||
of this software dedicate any and all copyright interest in the
|
||||
software to the public domain. We make this dedication for the benefit
|
||||
of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of
|
||||
relinquishment in perpetuity of all present and future rights to this
|
||||
software under copyright law.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more information, please refer to <http://unlicense.org>
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
# email-validator
|
||||
A simple module to validate an e-mail address
|
||||
|
||||
[](https://travis-ci.org/manishsaraan/email-validator)
|
||||
[]((http://npm.im/email-validator))
|
||||
[](https://npm-stat.com/charts.html?package=email-validators&from=2015-08-01)
|
||||
[](https://github.com/xojs/xo)
|
||||
|
||||
## Installation
|
||||
Install via NPM:
|
||||
|
||||
```bash
|
||||
npm install email-validator
|
||||
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
#### javascript
|
||||
|
||||
```javascript
|
||||
|
||||
var validator = require("email-validator");
|
||||
|
||||
validator.validate("test@email.com"); // true
|
||||
|
||||
```
|
||||
|
||||
#### TypeScript
|
||||
|
||||
```typescript
|
||||
|
||||
import * as EmailValidator from 'email-validator';
|
||||
|
||||
EmailValidator.validate("test@email.com"); // true
|
||||
|
||||
|
||||
```
|
||||
|
||||
## Contribute
|
||||
|
||||
Contributions welcome! Check the ``LICENSE`` file for more info.
|
||||
|
||||
## Meta
|
||||
|
||||
* robert@cosmicrealms.com
|
||||
* manish021js@gmail.com
|
||||
|
||||
Distributed under the unlicense public domain. See ``LICENSE`` for more information.
|
||||
|
||||
[https://github.com/manishsaraan/email-validator](https://github.com/manishsaraan/email-validator)
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.validate = validate;
|
||||
var tester = /^[-!#$%&'*+\/0-9=?A-Z^_a-z{|}~](\.?[-!#$%&'*+\/0-9=?A-Z^_a-z`{|}~])*@[a-zA-Z0-9](-?\.?[a-zA-Z0-9])*\.[a-zA-Z](-?[a-zA-Z0-9])+$/;
|
||||
// Thanks to:
|
||||
// http://fightingforalostcause.net/misc/2006/compare-email-regex.php
|
||||
// http://thedailywtf.com/Articles/Validating_Email_Addresses.aspx
|
||||
// http://stackoverflow.com/questions/201323/what-is-the-best-regular-expression-for-validating-email-addresses/201378#201378
|
||||
function validate(email) {
|
||||
if (!email) return false;
|
||||
|
||||
if (email.length > 254) return false;
|
||||
|
||||
var valid = tester.test(email);
|
||||
if (!valid) return false;
|
||||
|
||||
// Further checking of some things regex can't handle
|
||||
var parts = email.split("@");
|
||||
if (parts[0].length > 64) return false;
|
||||
|
||||
var domainParts = parts[1].split(".");
|
||||
if (domainParts.some(function (part) {
|
||||
return part.length > 63;
|
||||
})) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=index.cjs.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["index.js"],"names":[],"mappings":";;;;;QAKgB,Q,GAAA,Q;AALhB,IAAI,SAAS,gIAAb;AACA;AACA;AACA;AACA;AACO,SAAS,QAAT,CAAkB,KAAlB,EACP;AACC,KAAI,CAAC,KAAL,EACC,OAAO,KAAP;;AAED,KAAG,MAAM,MAAN,GAAa,GAAhB,EACC,OAAO,KAAP;;AAED,KAAI,QAAQ,OAAO,IAAP,CAAY,KAAZ,CAAZ;AACA,KAAG,CAAC,KAAJ,EACC,OAAO,KAAP;;AAED;AACA,KAAI,QAAQ,MAAM,KAAN,CAAY,GAAZ,CAAZ;AACA,KAAG,MAAM,CAAN,EAAS,MAAT,GAAgB,EAAnB,EACC,OAAO,KAAP;;AAED,KAAI,cAAc,MAAM,CAAN,EAAS,KAAT,CAAe,GAAf,CAAlB;AACA,KAAG,YAAY,IAAZ,CAAiB,UAAS,IAAT,EAAe;AAAE,SAAO,KAAK,MAAL,GAAY,EAAnB;AAAwB,EAA1D,CAAH,EACC,OAAO,KAAP;;AAED,QAAO,IAAP;AACA","file":"index.cjs.js","sourcesContent":["var tester = /^[-!#$%&'*+\\/0-9=?A-Z^_a-z{|}~](\\.?[-!#$%&'*+\\/0-9=?A-Z^_a-z`{|}~])*@[a-zA-Z0-9](-?\\.?[a-zA-Z0-9])*\\.[a-zA-Z](-?[a-zA-Z0-9])+$/;\r\n// Thanks to:\r\n// http://fightingforalostcause.net/misc/2006/compare-email-regex.php\r\n// http://thedailywtf.com/Articles/Validating_Email_Addresses.aspx\r\n// http://stackoverflow.com/questions/201323/what-is-the-best-regular-expression-for-validating-email-addresses/201378#201378\r\nexport function validate(email)\r\n{\r\n\tif (!email)\r\n\t\treturn false;\r\n\r\n\tif(email.length>254)\r\n\t\treturn false;\r\n\r\n\tvar valid = tester.test(email);\r\n\tif(!valid)\r\n\t\treturn false;\r\n\r\n\t// Further checking of some things regex can't handle\r\n\tvar parts = email.split(\"@\");\r\n\tif(parts[0].length>64)\r\n\t\treturn false;\r\n\r\n\tvar domainParts = parts[1].split(\".\");\r\n\tif(domainParts.some(function(part) { return part.length>63; }))\r\n\t\treturn false;\r\n\r\n\treturn true;\r\n}\r\n"]}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* Validate an email address.
|
||||
* @param {string} email - The email address to validate.
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function validate(email: string): boolean;
|
||||
|
||||
|
||||
/**
|
||||
* Async email validation.
|
||||
* @param {string} email - The email address to validate.
|
||||
* @param {AsyncCallback} callback - The callback to execute.
|
||||
*/
|
||||
export function validate_async(email: string, callback: AsyncCallback): void;
|
||||
|
||||
|
||||
export interface AsyncCallback {
|
||||
(err: any, isValideEmail: boolean): any;
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
|
||||
var tester = /^[-!#$%&'*+\/0-9=?A-Z^_a-z{|}~](\.?[-!#$%&'*+\/0-9=?A-Z^_a-z`{|}~])*@[a-zA-Z0-9](-*\.?[a-zA-Z0-9])*\.[a-zA-Z](-?[a-zA-Z0-9])+$/;
|
||||
// Thanks to:
|
||||
// http://fightingforalostcause.net/misc/2006/compare-email-regex.php
|
||||
// http://thedailywtf.com/Articles/Validating_Email_Addresses.aspx
|
||||
// http://stackoverflow.com/questions/201323/what-is-the-best-regular-expression-for-validating-email-addresses/201378#201378
|
||||
exports.validate = function(email)
|
||||
{
|
||||
if (!email)
|
||||
return false;
|
||||
|
||||
if(email.length>254)
|
||||
return false;
|
||||
|
||||
var valid = tester.test(email);
|
||||
if(!valid)
|
||||
return false;
|
||||
|
||||
// Further checking of some things regex can't handle
|
||||
var parts = email.split("@");
|
||||
if(parts[0].length>64)
|
||||
return false;
|
||||
|
||||
var domainParts = parts[1].split(".");
|
||||
if(domainParts.some(function(part) { return part.length>63; }))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
+123
@@ -0,0 +1,123 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "email-validator",
|
||||
"scope": null,
|
||||
"escapedName": "email-validator",
|
||||
"name": "email-validator",
|
||||
"rawSpec": "",
|
||||
"spec": "latest",
|
||||
"type": "tag"
|
||||
},
|
||||
"/Users/gerrit/Documents/dev/nodejs/rentfor.camp/html/RentForCamp"
|
||||
]
|
||||
],
|
||||
"_from": "email-validator@latest",
|
||||
"_id": "email-validator@2.0.4",
|
||||
"_inCache": true,
|
||||
"_location": "/email-validator",
|
||||
"_nodeVersion": "8.9.4",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "s3://npm-registry-packages",
|
||||
"tmp": "tmp/email-validator_2.0.4_1527419434839_0.057039834699951886"
|
||||
},
|
||||
"_npmUser": {
|
||||
"name": "manishsaraan",
|
||||
"email": "manish021js@gmail.com"
|
||||
},
|
||||
"_npmVersion": "5.6.0",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "email-validator",
|
||||
"scope": null,
|
||||
"escapedName": "email-validator",
|
||||
"name": "email-validator",
|
||||
"rawSpec": "",
|
||||
"spec": "latest",
|
||||
"type": "tag"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#USER",
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/email-validator/-/email-validator-2.0.4.tgz",
|
||||
"_shasum": "b8dfaa5d0dae28f1b03c95881d904d4e40bfe7ed",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "email-validator",
|
||||
"_where": "/Users/gerrit/Documents/dev/nodejs/rentfor.camp/html/RentForCamp",
|
||||
"author": {
|
||||
"name": "Manish Saraan",
|
||||
"email": "manish021js@gmail.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/manishsaraan/email-validator/issues"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Manish Saraan",
|
||||
"email": "manish021js@gmail.com",
|
||||
"url": "https://github.com/manishsaraan"
|
||||
},
|
||||
{
|
||||
"name": "Brad Martin",
|
||||
"email": "bradwaynemartin@gmail.com",
|
||||
"url": "https://github.com/bradmartin"
|
||||
}
|
||||
],
|
||||
"dependencies": {},
|
||||
"description": "Provides a fast, pretty robust e-mail validator. Only checks form, not function.",
|
||||
"devDependencies": {
|
||||
"chai": "4.1.2",
|
||||
"mocha": "5.0.5"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"integrity": "sha512-gYCwo7kh5S3IDyZPLZf6hSS0MnZT8QmJFqYvbqlDZSbwdZlY6QZWxJ4i/6UhITOJ4XzyI647Bm2MXKCLqnJ4nQ==",
|
||||
"shasum": "b8dfaa5d0dae28f1b03c95881d904d4e40bfe7ed",
|
||||
"tarball": "https://registry.npmjs.org/email-validator/-/email-validator-2.0.4.tgz",
|
||||
"fileCount": 10,
|
||||
"unpackedSize": 12056,
|
||||
"npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbCpIrCRA9TVsSAnZWagAA/R0P/RMoNh49ifRaFlWAIUBK\nsP9xZDBnJWToy5bvVxal1U7SlNtwmZ6TXoqr0NUFL3ZIP6c9xao2WTWIJgyE\nf4kgBNVNmWHf7wVUbdOJ7NGpFaqr/HT7/oemWYB2i9oUaqP2vZnfe6Mjk6Xa\nRbV91IgYSgWVkcrwpOCq7XKymgWk2YfOegZNsjjhQi4KEyC0bhFUZCdzJJXE\nyCzcudoHHL3V+7l/yxCCOJShPP8i+l6jH+KuikV98P4ziKpQL9s755lP3O0d\nofgcZFibH6dRXmFZoyJR7MSCOUU2upNcL3my+1jYU2ZXri8I9Zm8YOCJoWFo\nK+47Yx4fzjeTQqcnDJaybEQRl5O1jLrNIifm8FvFvM0EWS4TFAHigMyHmX0T\n0rPC8LRWU3RfmLWqyc4+Y1/nQ7dt0hGkiQpnXXQYymCwwMOr0ebyytVdK5Zw\nDiyOx4WRfDcXEtM3r6/LdLWAVUreX2zCDbdJeevsedXLf1NabR54d1cCnHHi\n1qqLFAwwHIA3zfeNpfSWZT798WzLETMVR3mRA1i+skIOslqDQ0yyuWF+DjwR\nIrhp0nlUJc9fm4odvy2Z0lz7Y0lbN0hrSgHGs6MBeA8a8XkFVTplbKRIadMA\ntwVmH60aRElvmlFMwL0C6+FWZQc9izPV/VQmxtCNN3wXIJuuQylJEOwZUd/6\n8vMo\r\n=TC7C\r\n-----END PGP SIGNATURE-----\r\n"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">4.0"
|
||||
},
|
||||
"gitHead": "01f8f712ea6b83b053132957c519cccfcdca6eac",
|
||||
"homepage": "http://github.com/manishsaraan/email-validator",
|
||||
"keywords": [
|
||||
"email",
|
||||
"validation",
|
||||
"validator",
|
||||
"syntax"
|
||||
],
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "http://github.com/manishsaraan/email-validator/raw/master/LICENSE"
|
||||
}
|
||||
],
|
||||
"main": "index",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "manishsaraan",
|
||||
"email": "manish021js@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "sembiance",
|
||||
"email": "robert@cosmicrealms.com"
|
||||
}
|
||||
],
|
||||
"name": "email-validator",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/manishsaraan/email-validator.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha test.js"
|
||||
},
|
||||
"typings": "index.d.ts",
|
||||
"version": "2.0.4"
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
const expect = require('chai').expect;
|
||||
const validator = require(".");
|
||||
|
||||
const validSupported =
|
||||
[
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@letters-in-local.org",
|
||||
"01234567890@numbers-in-local.net",
|
||||
"&'*+-./=?^_{}~@other-valid-characters-in-local.net",
|
||||
"mixed-1234-in-{+^}-local@sld.net",
|
||||
"a@single-character-in-local.org",
|
||||
"one-character-third-level@a.example.com",
|
||||
"single-character-in-sld@x.org",
|
||||
"local@dash-in-sld.com",
|
||||
"letters-in-sld@123.com",
|
||||
"one-letter-sld@x.org",
|
||||
"test@test--1.com",
|
||||
"uncommon-tld@sld.museum",
|
||||
"uncommon-tld@sld.travel",
|
||||
"uncommon-tld@sld.mobi",
|
||||
"country-code-tld@sld.uk",
|
||||
"country-code-tld@sld.rw",
|
||||
"local@sld.newTLD",
|
||||
"the-total-length@of-an-entire-address.cannot-be-longer-than-two-hundred-and-fifty-four-characters.and-this-address-is-254-characters-exactly.so-it-should-be-valid.and-im-going-to-add-some-more-words-here.to-increase-the-lenght-blah-blah-blah-blah-bla.org",
|
||||
"the-character-limit@for-each-part.of-the-domain.is-sixty-three-characters.this-is-exactly-sixty-three-characters-so-it-is-valid-blah-blah.com",
|
||||
"local@sub.domains.com",
|
||||
"backticks`are`legit@test.com",
|
||||
"digit-only-domain@123.com",
|
||||
"digit-only-domain-with-subdomain@sub.123.com"
|
||||
];
|
||||
|
||||
const validUnsupported =
|
||||
[
|
||||
"\"quoted\"@sld.com",
|
||||
"\"\\e\\s\\c\\a\\p\\e\\d\"@sld.com",
|
||||
"\"quoted-at-sign@sld.org\"@sld.com",
|
||||
"\"escaped\\\"quote\"@sld.com",
|
||||
"\"back\\slash\"@sld.com",
|
||||
"punycode-numbers-in-tld@sld.xn--3e0b707e",
|
||||
"bracketed-IP-instead-of-domain@[127.0.0.1]"
|
||||
];
|
||||
|
||||
const invalidSupported =
|
||||
[
|
||||
"@missing-local.org",
|
||||
"! #$%`|@invalid-characters-in-local.org",
|
||||
"(),:;`|@more-invalid-characters-in-local.org",
|
||||
"<>@[]\\`|@even-more-invalid-characters-in-local.org",
|
||||
".local-starts-with-dot@sld.com",
|
||||
"local-ends-with-dot.@sld.com",
|
||||
"two..consecutive-dots@sld.com",
|
||||
"partially.\"quoted\"@sld.com",
|
||||
"the-local-part-is-invalid-if-it-is-longer-than-sixty-four-characters@sld.net",
|
||||
"missing-sld@.com",
|
||||
"sld-starts-with-dashsh@-sld.com",
|
||||
"sld-ends-with-dash@sld-.com",
|
||||
"invalid-characters-in-sld@! \"#$%(),/;<>_[]`|.org",
|
||||
"missing-dot-before-tld@com",
|
||||
"missing-tld@sld.",
|
||||
"invalid",
|
||||
"the-total-length@of-an-entire-address.cannot-be-longer-than-two-hundred-and-fifty-four-characters.and-this-address-is-255-characters-exactly.so-it-should-be-invalid.and-im-going-to-add-some-more-words-here.to-increase-the-lenght-blah-blah-blah-blah-bl.org",
|
||||
"the-character-limit@for-each-part.of-the-domain.is-sixty-three-characters.this-is-exactly-sixty-four-characters-so-it-is-invalid-blah-blah.com",
|
||||
"missing-at-sign.net",
|
||||
"unbracketed-IP@127.0.0.1",
|
||||
"invalid-ip@127.0.0.1.26",
|
||||
"another-invalid-ip@127.0.0.256",
|
||||
"IP-and-port@127.0.0.1:25",
|
||||
"trailing-dots@test.de.",
|
||||
"dot-on-dot-in-domainname@te..st.de",
|
||||
"dot-first-in-domain@.test.de",
|
||||
"mg@ns.i"
|
||||
];
|
||||
describe('TEST EMAILS AGAINST VALIDATOR', () => {
|
||||
it('Should Be Valid', () => {
|
||||
validSupported.forEach( email => {
|
||||
expect(validator.validate(email)).to.equal(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('Should Be Invalid', () => {
|
||||
invalidSupported.forEach( email => {
|
||||
expect(validator.validate(email)).to.equal(false);
|
||||
});
|
||||
});
|
||||
|
||||
it('Should Be Invalid(UnSupported By Module)', () => {
|
||||
validUnsupported.forEach( email => {
|
||||
expect(validator.validate(email)).to.equal(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user