email-tld-validator 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +169 -0
- package/data/tlds.json +142 -0
- package/dist/index.cjs +1578 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.mjs +1573 -0
- package/dist/index.mjs.map +1 -0
- package/dist/index.native.js +1572 -0
- package/package.json +34 -0
package/README.md
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# email-tld-validator
|
|
2
|
+
|
|
3
|
+
Lightweight email validator with full IANA TLD validation. Zero dependencies. TypeScript included.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
* ✅ Email syntax validation
|
|
8
|
+
* ✅ Local-part validation (length, characters, dot rules)
|
|
9
|
+
* ✅ Domain validation (labels, hyphens, length limits)
|
|
10
|
+
* ✅ TLD validation against the official IANA Root Zone Database
|
|
11
|
+
* ✅ Supports 1,437+ active TLDs
|
|
12
|
+
* ✅ TypeScript support
|
|
13
|
+
* ✅ Zero runtime dependencies
|
|
14
|
+
* ✅ Fast and lightweight
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install email-tld-validator
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
### CommonJS
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
const {
|
|
28
|
+
validateEmail,
|
|
29
|
+
isValidEmail,
|
|
30
|
+
getTLDs
|
|
31
|
+
} = require('email-tld-validator');
|
|
32
|
+
|
|
33
|
+
validateEmail('user@example.com');
|
|
34
|
+
// { valid: true }
|
|
35
|
+
|
|
36
|
+
isValidEmail('user@example.com');
|
|
37
|
+
// true
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### ES Modules
|
|
41
|
+
|
|
42
|
+
```js
|
|
43
|
+
import {
|
|
44
|
+
validateEmail,
|
|
45
|
+
isValidEmail,
|
|
46
|
+
getTLDs
|
|
47
|
+
} from 'email-tld-validator';
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Examples
|
|
51
|
+
|
|
52
|
+
### Detailed Validation
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
validateEmail('user@example.com');
|
|
56
|
+
// { valid: true }
|
|
57
|
+
|
|
58
|
+
validateEmail('user@example.invalid');
|
|
59
|
+
// {
|
|
60
|
+
// valid: false,
|
|
61
|
+
// reason: '"invalid" is not a recognized TLD'
|
|
62
|
+
// }
|
|
63
|
+
|
|
64
|
+
validateEmail('.bad@example.com');
|
|
65
|
+
// {
|
|
66
|
+
// valid: false,
|
|
67
|
+
// reason: 'Invalid characters or format in local part (before @)'
|
|
68
|
+
// }
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Boolean Validation
|
|
72
|
+
|
|
73
|
+
```js
|
|
74
|
+
isValidEmail('user@example.com');
|
|
75
|
+
// true
|
|
76
|
+
|
|
77
|
+
isValidEmail('not-an-email');
|
|
78
|
+
// false
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Access Supported TLDs
|
|
82
|
+
|
|
83
|
+
```js
|
|
84
|
+
const tlds = getTLDs();
|
|
85
|
+
|
|
86
|
+
tlds.has('com'); // true
|
|
87
|
+
tlds.has('dev'); // true
|
|
88
|
+
|
|
89
|
+
console.log(tlds.size);
|
|
90
|
+
// 1437+
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## TypeScript
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
import {
|
|
97
|
+
validateEmail,
|
|
98
|
+
isValidEmail,
|
|
99
|
+
getTLDs,
|
|
100
|
+
ValidationResult
|
|
101
|
+
} from 'email-tld-validator';
|
|
102
|
+
|
|
103
|
+
const result: ValidationResult =
|
|
104
|
+
validateEmail('user@example.com');
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## API
|
|
108
|
+
|
|
109
|
+
### `validateEmail(email: string): ValidationResult`
|
|
110
|
+
|
|
111
|
+
Performs full email validation.
|
|
112
|
+
|
|
113
|
+
Returns:
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
{ valid: true }
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
or
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
{
|
|
123
|
+
valid: false,
|
|
124
|
+
reason: string
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### `isValidEmail(email: string): boolean`
|
|
129
|
+
|
|
130
|
+
Convenience helper that returns only a boolean result.
|
|
131
|
+
|
|
132
|
+
Equivalent to:
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
validateEmail(email).valid
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### `getTLDs(): Set<string>`
|
|
139
|
+
|
|
140
|
+
Returns a copy of the internal TLD set used for validation.
|
|
141
|
+
|
|
142
|
+
## Validation Rules
|
|
143
|
+
|
|
144
|
+
| Check | Rule |
|
|
145
|
+
| --------------------- | ----------------------------------------- |
|
|
146
|
+
| Local part characters | `a-z A-Z 0-9 . _ % + -` |
|
|
147
|
+
| Local part length | Maximum 64 characters |
|
|
148
|
+
| Local part dots | No leading, trailing, or consecutive dots |
|
|
149
|
+
| Domain label | Alphanumeric and hyphens only |
|
|
150
|
+
| Domain label length | Maximum 63 characters |
|
|
151
|
+
| Domain label hyphens | Cannot start or end with `-` |
|
|
152
|
+
| Domain length | Maximum 253 characters |
|
|
153
|
+
| Email length | Maximum 254 characters |
|
|
154
|
+
| TLD validation | Must exist in the IANA Root Zone Database |
|
|
155
|
+
|
|
156
|
+
## Notes
|
|
157
|
+
|
|
158
|
+
This package validates email format and TLD existence only.
|
|
159
|
+
|
|
160
|
+
It does **not**:
|
|
161
|
+
|
|
162
|
+
* Verify mailbox existence
|
|
163
|
+
* Perform SMTP checks
|
|
164
|
+
* Check MX records
|
|
165
|
+
* Detect disposable email providers
|
|
166
|
+
|
|
167
|
+
## License
|
|
168
|
+
|
|
169
|
+
MIT
|
package/data/tlds.json
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
{
|
|
2
|
+
"source": "IANA Root Zone Database",
|
|
3
|
+
"updatedAt": "2026-06-13",
|
|
4
|
+
"count": 1437,
|
|
5
|
+
"tlds": [
|
|
6
|
+
"aaa","aarp","abb","abbott","abbvie","abc","able","abogado","abudhabi","ac",
|
|
7
|
+
"academy","accenture","accountant","accountants","aco","actor","ad","ads",
|
|
8
|
+
"adult","ae","aeg","aero","aetna","af","afl","africa","ag","agakhan","agency",
|
|
9
|
+
"ai","aig","airbus","airforce","airtel","akdn","al","alibaba","alipay",
|
|
10
|
+
"allfinanz","allstate","ally","alsace","alstom","am","amazon",
|
|
11
|
+
"americanexpress","americanfamily","amex","amfam","amica","amsterdam",
|
|
12
|
+
"analytics","android","anquan","anz","ao","aol","apartments","app","apple",
|
|
13
|
+
"aq","aquarelle","ar","arab","aramco","archi","army","arpa","art","arte","as",
|
|
14
|
+
"asda","asia","associates","at","athleta","attorney","au","auction","audi",
|
|
15
|
+
"audible","audio","auspost","author","auto","autos","aw","aws","ax","axa","az",
|
|
16
|
+
"azure","ba","baby","baidu","banamex","band","bank","bar","barcelona",
|
|
17
|
+
"barclaycard","barclays","barefoot","bargains","baseball","basketball",
|
|
18
|
+
"bauhaus","bayern","bb","bbc","bbt","bbva","bcg","bcn","bd","be","beats",
|
|
19
|
+
"beauty","beer","berlin","best","bestbuy","bet","bf","bg","bh","bharti","bi",
|
|
20
|
+
"bible","bid","bike","bing","bingo","bio","biz","bj","black","blackfriday",
|
|
21
|
+
"blockbuster","blog","bloomberg","blue","bm","bms","bmw","bn","bnpparibas",
|
|
22
|
+
"bo","boats","boehringer","bofa","bom","bond","boo","book","booking","bosch",
|
|
23
|
+
"bostik","boston","bot","boutique","box","br","bradesco","bridgestone",
|
|
24
|
+
"broadway","broker","brother","brussels","bs","bt","build","builders",
|
|
25
|
+
"business","buy","buzz","bv","bw","by","bz","bzh","ca","cab","cafe","cal",
|
|
26
|
+
"call","calvinklein","cam","camera","camp","canon","capetown","capital",
|
|
27
|
+
"capitalone","car","caravan","cards","care","career","careers","cars","casa",
|
|
28
|
+
"case","cash","casino","cat","catering","catholic","cba","cbn","cbre","cc",
|
|
29
|
+
"cd","center","ceo","cern","cf","cfa","cfd","cg","ch","chanel","channel",
|
|
30
|
+
"charity","chase","chat","cheap","chintai","christmas","chrome","church","ci",
|
|
31
|
+
"cipriani","circle","cisco","citadel","citi","citic","city","ck","cl","claims",
|
|
32
|
+
"cleaning","click","clinic","clinique","clothing","cloud","club","clubmed",
|
|
33
|
+
"cm","cn","co","coach","codes","coffee","college","cologne","com","commbank",
|
|
34
|
+
"community","company","compare","computer","comsec","condos","construction",
|
|
35
|
+
"consulting","contact","contractors","cooking","cool","coop","corsica",
|
|
36
|
+
"country","coupon","coupons","courses","cpa","cr","credit","creditcard",
|
|
37
|
+
"creditunion","cricket","crown","crs","cruise","cruises","cu","cuisinella",
|
|
38
|
+
"cv","cw","cx","cy","cymru","cyou","cz","dad","dance","data","date","dating",
|
|
39
|
+
"datsun","day","dclk","dds","de","deal","dealer","deals","degree","delivery",
|
|
40
|
+
"dell","deloitte","delta","democrat","dental","dentist","desi","design","dev",
|
|
41
|
+
"dhl","diamonds","diet","digital","direct","directory","discount","discover",
|
|
42
|
+
"dish","diy","dj","dk","dm","dnp","do","docs","doctor","dog","domains","dot",
|
|
43
|
+
"download","drive","dtv","dubai","dupont","durban","dvag","dvr","dz","earth",
|
|
44
|
+
"eat","ec","eco","edeka","edu","education","ee","eg","email","emerck","energy",
|
|
45
|
+
"engineer","engineering","enterprises","epson","equipment","er","ericsson",
|
|
46
|
+
"erni","es","esq","estate","et","eu","eurovision","eus","events","exchange",
|
|
47
|
+
"expert","exposed","express","extraspace","fage","fail","fairwinds","faith",
|
|
48
|
+
"family","fan","fans","farm","farmers","fashion","fast","fedex","feedback",
|
|
49
|
+
"ferrari","ferrero","fi","fidelity","fido","film","final","finance","financial",
|
|
50
|
+
"fire","firestone","firmdale","fish","fishing","fit","fitness","fj","fk",
|
|
51
|
+
"flickr","flights","flir","florist","flowers","fly","fm","fo","foo","food",
|
|
52
|
+
"football","ford","forex","forsale","forum","foundation","fox","fr","free",
|
|
53
|
+
"fresenius","frl","frogans","frontier","ftr","fujitsu","fun","fund",
|
|
54
|
+
"furniture","futbol","fyi","ga","gal","gallery","gallo","gallup","game",
|
|
55
|
+
"games","gap","garden","gay","gb","gbiz","gd","gdn","ge","gea","gent",
|
|
56
|
+
"genting","george","gf","gg","ggee","gh","gi","gift","gifts","gives","giving",
|
|
57
|
+
"gl","glass","gle","global","globo","gm","gmail","gmbh","gmo","gmx","gn",
|
|
58
|
+
"godaddy","gold","goldpoint","golf","goodyear","goog","google","gop","got",
|
|
59
|
+
"gov","gp","gq","gr","grainger","graphics","gratis","green","gripe","grocery",
|
|
60
|
+
"group","gs","gt","gu","gucci","guge","guide","guitars","guru","gw","gy",
|
|
61
|
+
"hair","hamburg","hangout","haus","hbo","hdfc","hdfcbank","health","healthcare",
|
|
62
|
+
"help","helsinki","here","hermes","hiphop","hisamitsu","hitachi","hiv","hk",
|
|
63
|
+
"hkt","hm","hn","hockey","holdings","holiday","homedepot","homegoods","homes",
|
|
64
|
+
"homesense","honda","horse","hospital","host","hosting","hot","hotels",
|
|
65
|
+
"hotmail","house","how","hr","hsbc","ht","hu","hughes","hyatt","hyundai","ibm",
|
|
66
|
+
"icbc","ice","icu","id","ie","ieee","ifm","ikano","il","im","imamat","imdb",
|
|
67
|
+
"immo","immobilien","in","inc","industries","infiniti","info","ing","ink",
|
|
68
|
+
"institute","insurance","insure","int","international","intuit","investments",
|
|
69
|
+
"io","ipiranga","iq","ir","irish","is","ismaili","ist","istanbul","it","itau",
|
|
70
|
+
"itv","jaguar","java","jcb","je","jeep","jetzt","jewelry","jio","jll","jm",
|
|
71
|
+
"jmp","jnj","jo","jobs","joburg","jot","joy","jp","jpmorgan","jprs","juegos",
|
|
72
|
+
"juniper","kaufen","kddi","ke","kerryhotels","kerryproperties","kfh","kg","kh",
|
|
73
|
+
"ki","kia","kids","kim","kindle","kitchen","kiwi","km","kn","koeln","komatsu",
|
|
74
|
+
"kosher","kp","kpmg","kpn","kr","krd","kred","kuokgroup","kw","ky","kyoto",
|
|
75
|
+
"kz","la","lacaixa","lamborghini","lamer","land","landrover","lanxess",
|
|
76
|
+
"lasalle","lat","latino","latrobe","law","lawyer","lb","lc","lds","lease",
|
|
77
|
+
"leclerc","lefrak","legal","lego","lexus","lgbt","li","lidl","life",
|
|
78
|
+
"lifeinsurance","lifestyle","lighting","like","lilly","limited","limo",
|
|
79
|
+
"lincoln","link","live","living","lk","llc","llp","loan","loans","locker",
|
|
80
|
+
"locus","lol","london","lotte","lotto","love","lpl","lplfinancial","lr","ls",
|
|
81
|
+
"lt","ltd","ltda","lu","lundbeck","luxe","luxury","lv","ly","ma","madrid",
|
|
82
|
+
"maif","maison","makeup","man","management","mango","map","market","marketing",
|
|
83
|
+
"markets","marriott","marshalls","mattel","mba","mc","mckinsey","md","me",
|
|
84
|
+
"med","media","meet","melbourne","meme","memorial","men","menu","merck",
|
|
85
|
+
"merckmsd","mg","mh","miami","microsoft","mil","mini","mint","mit","mitsubishi",
|
|
86
|
+
"mk","ml","mlb","mls","mm","mma","mn","mo","mobi","mobile","moda","moe","moi",
|
|
87
|
+
"mom","monash","money","monster","mormon","mortgage","moscow","moto",
|
|
88
|
+
"motorcycles","mov","movie","mp","mq","mr","ms","msd","mt","mtn","mtr","mu",
|
|
89
|
+
"museum","music","mv","mw","mx","my","mz","na","nab","nagoya","name","navy",
|
|
90
|
+
"nba","nc","ne","nec","net","netbank","netflix","network","neustar","new",
|
|
91
|
+
"news","next","nextdirect","nexus","nf","nfl","ng","ngo","nhk","ni","nico",
|
|
92
|
+
"nike","nikon","ninja","nissan","nissay","nl","no","nokia","norton","now",
|
|
93
|
+
"nowruz","nowtv","np","nr","nra","nrw","ntt","nu","nyc","nz","obi","observer",
|
|
94
|
+
"office","okinawa","olayan","olayangroup","ollo","om","omega","one","ong","onl",
|
|
95
|
+
"online","ooo","open","oracle","orange","org","organic","origins","osaka",
|
|
96
|
+
"otsuka","ott","ovh","pa","page","panasonic","paris","pars","partners","parts",
|
|
97
|
+
"party","pay","pccw","pe","pet","pf","pfizer","pg","ph","pharmacy","phd",
|
|
98
|
+
"philips","phone","photo","photography","photos","physio","pics","pictet",
|
|
99
|
+
"pictures","pid","pin","ping","pink","pioneer","pizza","pk","pl","place","play",
|
|
100
|
+
"playstation","plumbing","plus","pm","pn","pnc","pohl","poker","politie","porn",
|
|
101
|
+
"post","pr","praxi","press","prime","pro","prod","productions","prof",
|
|
102
|
+
"progressive","promo","properties","property","protection","pru","prudential",
|
|
103
|
+
"ps","pt","pub","pw","pwc","py","qa","qpon","quebec","quest","racing","radio",
|
|
104
|
+
"re","read","realestate","realtor","realty","recipes","red","redumbrella",
|
|
105
|
+
"rehab","reise","reisen","reit","reliance","ren","rent","rentals","repair",
|
|
106
|
+
"report","republican","rest","restaurant","review","reviews","rexroth","rich",
|
|
107
|
+
"richardli","ricoh","ril","rio","rip","ro","rocks","rodeo","rogers","room","rs",
|
|
108
|
+
"rsvp","ru","rugby","ruhr","run","rw","rwe","ryukyu","sa","saarland","safe",
|
|
109
|
+
"safety","sakura","sale","salon","samsclub","samsung","sandvik",
|
|
110
|
+
"sandvikcoromant","sanofi","sap","sarl","sas","save","saxo","sb","sbi","sbs",
|
|
111
|
+
"sc","scb","schaeffler","schmidt","scholarships","school","schule","schwarz",
|
|
112
|
+
"science","scot","sd","se","search","seat","secure","security","seek","select",
|
|
113
|
+
"sener","services","seven","sew","sex","sexy","sfr","sg","sh","shangrila",
|
|
114
|
+
"sharp","shell","shia","shiksha","shoes","shop","shopping","shouji","show","si",
|
|
115
|
+
"silk","sina","singles","site","sj","sk","ski","skin","sky","skype","sl",
|
|
116
|
+
"sling","sm","smart","smile","sn","sncf","so","soccer","social","softbank",
|
|
117
|
+
"software","sohu","solar","solutions","song","sony","soy","spa","space","sport",
|
|
118
|
+
"spot","sr","srl","ss","st","stada","staples","star","statebank","statefarm",
|
|
119
|
+
"stc","stcgroup","stockholm","storage","store","stream","studio","study",
|
|
120
|
+
"style","su","sucks","supplies","supply","support","surf","surgery","suzuki",
|
|
121
|
+
"sv","swatch","swiss","sx","sy","sydney","systems","sz","tab","taipei","talk",
|
|
122
|
+
"taobao","target","tatamotors","tatar","tattoo","tax","taxi","tc","tci","td",
|
|
123
|
+
"tdk","team","tech","technology","tel","temasek","tennis","teva","tf","tg","th",
|
|
124
|
+
"thd","theater","theatre","tiaa","tickets","tienda","tips","tires","tirol","tj",
|
|
125
|
+
"tjmaxx","tjx","tk","tkmaxx","tl","tm","tmall","tn","to","today","tokyo",
|
|
126
|
+
"tools","top","toray","toshiba","total","tours","town","toyota","toys","tr",
|
|
127
|
+
"trade","trading","training","travel","travelers","travelersinsurance","trust",
|
|
128
|
+
"trv","tt","tube","tui","tunes","tushu","tv","tvs","tw","tz","ua","ubank","ubs",
|
|
129
|
+
"ug","uk","unicom","university","uno","uol","ups","us","uy","uz","va",
|
|
130
|
+
"vacations","vana","vanguard","vc","ve","vegas","ventures","verisign",
|
|
131
|
+
"versicherung","vet","vg","vi","viajes","video","vig","viking","villas","vin",
|
|
132
|
+
"vip","virgin","visa","vision","viva","vivo","vlaanderen","vn","vodka","volvo",
|
|
133
|
+
"vote","voting","voto","voyage","vu","wales","walmart","walter","wang",
|
|
134
|
+
"wanggou","watch","watches","weather","weatherchannel","webcam","weber",
|
|
135
|
+
"website","wed","wedding","weibo","weir","wf","whoswho","wien","wiki",
|
|
136
|
+
"williamhill","win","windows","wine","winners","wme","woodside","work","works",
|
|
137
|
+
"world","wow","ws","wtc","wtf","xbox","xerox","xihuan","xin",
|
|
138
|
+
"xxx","xyz","yachts","yahoo","yamaxun","yandex","ye","yodobashi","yoga",
|
|
139
|
+
"yokohama","you","youtube","yt","yun","za","zappos","zara","zero","zip","zm",
|
|
140
|
+
"zone","zuerich","zw"
|
|
141
|
+
]
|
|
142
|
+
}
|