-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
104 lines (99 loc) · 3.84 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
const DB = `PYmt8hd,jdcrLI,[email protected],27,London
aN21Mhj,yoHrWHE,oHrWHE@example,40,
,oHrWHE,[email protected],a,
2RVxZLzIcs,jvNCJj,[email protected],45,Berlin
XUOUmi9,utuPMN,htuPMN@invalid,,Berlin
UXMmi9,htuPMN,@@@.com,,Berlin
Y2FCxmg*E4L,4vZtIH,[email protected],27,London
Y2FgXXE4L,DvZtIH,[email protected],27,London
wYR2DOE,vsWtBk,vsWtBk@example,,Paris
(MIDUni,3vsWtBk,[email protected],,Barcelona
G1WV7gK,RFHWCi,[email protected],53,Sydney
OQc_YTY,bGyjPo,,,BuenosAires
OQc_YTY,eGyjPo,bGyjPo@example,,Caracas
uzHXNR,IFLUDB,[email protected],46,Madrid
u56gsjt,eBbEBV,eBbEBV@invalid,49,
QH87Wd,fImzHM,[email protected],38,Madrid
Dhy92jh,pB1P64,[email protected],52,CDMX
6DkGW62P,ldmcDE,[email protected],33,Madrid
B89dht_,nceCp2,nceCp2@invalid,68,Rome
O8TsZ7,jauTbB,[email protected],45,New York
tIR9N,yOkZBg,[email protected],68,Tokyo
1KN4ZOe,emuBwK,[email protected],27,London
2efL9,zAPgvK,[email protected],33,Paris
f9Fw1q6tWq,djrWrL,[email protected],20,New York
weoFk,prYGAC,hrygac@yahoocom,19,Sydney
mZf2R,LnSBAh,[email protected],18,Paris
KIuLH,kKpddF,[email protected],32,Rome
4359Rm,LAlhya,[email protected],62,London
KYQZq9yg,ZTvLpI,[email protected],27,Madrid
9hC&UV8,wWZxgp,[email protected],49,Madrid
ra7wsGC,DFgbNn,[email protected],40,New York
0=uUIzOsDN,ngPCGN,[email protected],57,Rome
zaor8f,WXQwzY,[email protected],27,Paris
KTMoYqn,ZFSwLp,[email protected],57,Berlin
OJMgD,mmJyyc,[email protected],30,Paris
J49HyU,udMyki,[email protected],35,Rome
ZBiXSV,gQXcjA,[email protected],68,Paris
lP6GLm6,ljiCsY,[email protected],45,Berlin
neZAj,bBIbVF,[email protected],58,London
9uLq2KwoIr,OWXXBl,[email protected],46,Sydney
RELT7fgmnD,dplQIl,,58,New York
HDKVi,AxLzOk,[email protected],68,New York
Mp7lqou9z,SJzlEy,[email protected],63,London
6rDP6BCQv,nnqyAa,[email protected],45,New York
OyH2qjKxZ,nwWZuw,[email protected],56,Rome
L8DHMmE44p,MoAcMe,[email protected],67,Paris
TlSmF,fPmepA,[email protected],42,Rome
E1QH9ci7,hlyLQF,[email protected],41,New York
mYOpY23,SHmAju,[email protected],64,Rome
XAEJitTlla,qrpsKE,[email protected],52,Rome
tS4XE,DoxbRW,[email protected],26,Tokyo
zGmt6Bg,JXcvKW,[email protected],68,Madrid
4t7td1EpM,cnxBsn,[email protected],42,Madrid
USYVWP9,Zhszyq,[email protected],45,Berlin
xPsBdFX,guBqHO,[email protected],56,Berlin
vjs0muFgD,GlNbyN,[email protected],43,Paris
MJjqv,lfmiGU,[email protected],60,London
jZlHAbXel,YOfnFV,[email protected],38,Tokyo
IykL8QNPN,ndBTcB,[email protected],28,Berlin
Vq7WI4,CLCYRN,[email protected],25,Tokyo
utGGulT,RdmXuh,[email protected],68,Rome
FQeos5,aMlzfe,[email protected],43,Berlin
bJKfMUASk,RnEDLz,[email protected],36,Berlin
p3GXT0,Meohff,[email protected],27,Madrid
TCsiyDQpIl,FdMArs,[email protected],63,Berlin
cb6RRrx,ZCyfir,[email protected],45,Rome
Fm7V1tR34,VJlNXN,[email protected],32,Rome
VY5EHZHY,EfaHWA,[email protected],25,New York
EkCCjg5e9,JvowjF,[email protected],68,Paris
KVJd37LC,IzgjKS,[email protected],31,Paris`;
const invalidUsersFirstLetters = [];
const REGEXS = {
id: /^[a-z0-9]+$/i,
username: /^[a-z0-9]+$/i,
email:
/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
age: /^\d+$/,
location: /^\w+(\s+\w+)*$/,
};
const validRow = (row) => {
const { id, username, email, age, location } = row;
return (
id.length > 0 &&
REGEXS['id'].test(id) &&
username.length > 0 &&
REGEXS['username'].test(username) &&
email.length > 0 &&
REGEXS['email'].test(email) &&
(age.length === 0 || REGEXS['age'].test(age)) &&
(location.length === 0 || REGEXS['location'].test(location))
);
};
DB.split('\n').forEach((dbRow) => {
const [id, username, email, age, location] = dbRow.split(',');
if (!validRow({ id, username, email, age, location })) {
invalidUsersFirstLetters.push(username.split('')[0]);
}
});
console.log(`submit ${invalidUsersFirstLetters.join('')}`);