1 | "use strict";
|
2 |
|
3 | var validator = require("./index");
|
4 |
|
5 | var 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 | ];
|
27 |
|
28 | var validUnsupported =
|
29 | [
|
30 | "\"quoted\"@sld.com",
|
31 | "\"\\e\\s\\c\\a\\p\\e\\d\"@sld.com",
|
32 | "\"quoted-at-sign@sld.org\"@sld.com",
|
33 | "\"escaped\\\"quote\"@sld.com",
|
34 | "\"back\\slash\"@sld.com",
|
35 | "punycode-numbers-in-tld@sld.xn--3e0b707e",
|
36 | "bracketed-IP-instead-of-domain@[127.0.0.1]"
|
37 | ];
|
38 |
|
39 | var invalidSupported =
|
40 | [
|
41 | "@missing-local.org",
|
42 | "! #$%`|@invalid-characters-in-local.org",
|
43 | "(),:;`|@more-invalid-characters-in-local.org",
|
44 | "<>@[]\\`|@even-more-invalid-characters-in-local.org",
|
45 | ".local-starts-with-dot@sld.com",
|
46 | "local-ends-with-dot.@sld.com",
|
47 | "two..consecutive-dots@sld.com",
|
48 | "partially.\"quoted\"@sld.com",
|
49 | "the-local-part-is-invalid-if-it-is-longer-than-sixty-four-characters@sld.net",
|
50 | "missing-sld@.com",
|
51 | "sld-starts-with-dashsh@-sld.com",
|
52 | "sld-ends-with-dash@sld-.com",
|
53 | "invalid-characters-in-sld@! \"#$%(),/;<>_[]`|.org",
|
54 | "missing-dot-before-tld@com",
|
55 | "missing-tld@sld.",
|
56 | "invalid",
|
57 | "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",
|
58 | "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",
|
59 | "missing-at-sign.net",
|
60 | "unbracketed-IP@127.0.0.1",
|
61 | "invalid-ip@127.0.0.1.26",
|
62 | "another-invalid-ip@127.0.0.256",
|
63 | "IP-and-port@127.0.0.1:25"
|
64 | ];
|
65 |
|
66 | console.log("SUPPORTED BY MODULE:\n");
|
67 |
|
68 | console.log("SHOULD BE VALID:");
|
69 | validSupported.forEach(function(email) { console.log("%s : %s", validator.validate(email) ? " VALID" : " INVALID", email); });
|
70 |
|
71 | console.log("\nSHOULD BE INVALID:");
|
72 | invalidSupported.forEach(function(email) { console.log("%s : %s", validator.validate(email) ? " VALID" : " INVALID", email); });
|
73 |
|
74 | console.log("\n\nNOT SUPPORTED BY MODULE:\n");
|
75 |
|
76 | console.log("SHOULD BE VALID:");
|
77 | validUnsupported.forEach(function(email) { console.log("%s : %s", validator.validate(email) ? " VALID" : " INVALID", email); });
|
78 |
|
79 | process.exit(0);
|