UNPKG

3.16 kBJavaScriptView Raw
1"use strict";
2
3var validator = require("./index");
4
5var validSupported =
6[
7 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@letters-in-local.org",
8 "01234567890@numbers-in-local.net",
9 "&'*+-./=?^_{}~@other-valid-characters-in-local.net",
10 "mixed-1234-in-{+^}-local@sld.net",
11 "a@single-character-in-local.org",
12 "one-character-third-level@a.example.com",
13 "single-character-in-sld@x.org",
14 "local@dash-in-sld.com",
15 "letters-in-sld@123.com",
16 "one-letter-sld@x.org",
17 "uncommon-tld@sld.museum",
18 "uncommon-tld@sld.travel",
19 "uncommon-tld@sld.mobi",
20 "country-code-tld@sld.uk",
21 "country-code-tld@sld.rw",
22 "local@sld.newTLD",
23 "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",
24 "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",
25 "local@sub.domains.com",
26 "backticks`are`legit@test.com"
27];
28
29var validUnsupported =
30[
31 "\"quoted\"@sld.com",
32 "\"\\e\\s\\c\\a\\p\\e\\d\"@sld.com",
33 "\"quoted-at-sign@sld.org\"@sld.com",
34 "\"escaped\\\"quote\"@sld.com",
35 "\"back\\slash\"@sld.com",
36 "punycode-numbers-in-tld@sld.xn--3e0b707e",
37 "bracketed-IP-instead-of-domain@[127.0.0.1]"
38];
39
40var invalidSupported =
41[
42 "@missing-local.org",
43 "! #$%`|@invalid-characters-in-local.org",
44 "(),:;`|@more-invalid-characters-in-local.org",
45 "<>@[]\\`|@even-more-invalid-characters-in-local.org",
46 ".local-starts-with-dot@sld.com",
47 "local-ends-with-dot.@sld.com",
48 "two..consecutive-dots@sld.com",
49 "partially.\"quoted\"@sld.com",
50 "the-local-part-is-invalid-if-it-is-longer-than-sixty-four-characters@sld.net",
51 "missing-sld@.com",
52 "sld-starts-with-dashsh@-sld.com",
53 "sld-ends-with-dash@sld-.com",
54 "invalid-characters-in-sld@! \"#$%(),/;<>_[]`|.org",
55 "missing-dot-before-tld@com",
56 "missing-tld@sld.",
57 "invalid",
58 "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",
59 "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",
60 "missing-at-sign.net",
61 "unbracketed-IP@127.0.0.1",
62 "invalid-ip@127.0.0.1.26",
63 "another-invalid-ip@127.0.0.256",
64 "IP-and-port@127.0.0.1:25"
65];
66
67console.log("SUPPORTED BY MODULE:\n");
68
69console.log("SHOULD BE VALID:");
70validSupported.forEach(function(email) { console.log("%s : %s", validator.validate(email) ? " VALID" : " INVALID", email); });
71
72console.log("\nSHOULD BE INVALID:");
73invalidSupported.forEach(function(email) { console.log("%s : %s", validator.validate(email) ? " VALID" : " INVALID", email); });
74
75console.log("\n\nNOT SUPPORTED BY MODULE:\n");
76
77console.log("SHOULD BE VALID:");
78validUnsupported.forEach(function(email) { console.log("%s : %s", validator.validate(email) ? " VALID" : " INVALID", email); });
79
80process.exit(0);