Skip to content

Password Validated #17

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 53 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1 +1,53 @@
// Do work!
// Do work!
function validatePassword (password) {
let finalCheck = true
let numberOfCharacters = true
let oneLowerCase = true
let oneUpperCase = true
let numericValue = true
let specialCharacter = true
let loCase = /[a-z]/
let upCase = /[A-Z]/
let numValue = /[0-9]/
let speChar = /[!@#$%^&*()_+=<>?/"':;,.{}]/

if(password.length >= 8) {
numberOfCharacters = true

}else{
numberOfCharacters = false
}

if(upCase.test(password)){
oneUpperCase = true
}else{
oneUpperCase = false
}

if(loCase.test(password)){
oneLowerCase = true
}else{
oneLowerCase = false
}

if(numValue.test(password)){
numericValue = true
}else{
numericValue = false
}

if(speChar.test(password)){
specialCharacter = true
}else{
specialCharacter = false
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the naming of finalCheck here. Nicely done.

if (numberOfCharacters == true && oneUpperCase == true && specialCharacter == true && numericValue == true && oneLowerCase == true ){
finalCheck = true
}else{
finalCheck = false
}
return finalCheck
}

module.exports = validatePassword
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"lint": "eslint --format codeframe .",
"lint:fix": "eslint --fix --format codeframe .",
"test": "mocha -w"
"test": "mocha"
},
"repository": {
"type": "git",
Expand Down