Skip to content

Commit eac47a4

Browse files
committed
Work on password validator
1 parent f3b13d5 commit eac47a4

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
const previousPasswords = ["Pass1!", "Hello1#", "Secure1$"];
22

33
function passwordValidator(password) {
4-
if (password.length < 5) return false;
5-
if (!/[A-Z]/.test(password)) return false;
6-
if (!/[a-z]/.test(password)) return false;
7-
if (!/[0-9]/.test(password)) return false;
8-
if (!/[!#$%.*&]/.test(password)) return false;
9-
if (previousPasswords.includes(password)) return false;
4+
if (password.length < 5) {
5+
return false;
6+
} if (!/[A-Z]/.test(password)) {
7+
return false;
8+
} if (!/[a-z]/.test(password)) {
9+
return false;
10+
} if (!/[0-9]/.test(password)) {
11+
return false;
12+
} if (!/[!#$%.\*&]/.test(password)) {
13+
return false;
14+
} if (previousPasswords.includes(password)) {
15+
return false;
16+
}
1017
return true;
1118
}
1219

13-
module.exports = { passwordValidator, previousPasswords };
20+
module.exports = { passwordValidator, previousPasswords };

0 commit comments

Comments
 (0)