Skip to content

Commit 8499ca3

Browse files
committed
Editing passwordValidator code
1 parent 6b8d975 commit 8499ca3

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed
Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,30 @@
1-
function passwordValidator(password) {
2-
return password.length < 5 ? false : true
3-
}
1+
const passwords = ["Amtf22#", "123$cdo"];
2+
function passwordValidator(password) {
3+
if (password.length < 5) {
4+
return false;
5+
}
6+
7+
if (!/[A-Z]/.test(password)) {
8+
return false;
9+
}
10+
11+
if (!/[a-z]/.test(password)) {
12+
return false;
13+
}
14+
15+
if (!/[0-9]/.test(password)) {
16+
return false;
17+
}
18+
if (!/[!#$%&? "]/.test(password)) {
19+
return false;
20+
}
421

22+
if (passwords.includes(password)) {
23+
return false;
24+
}
25+
26+
27+
return true;
28+
}
529

630
module.exports = passwordValidator;

0 commit comments

Comments
 (0)