Skip to content
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
1 change: 0 additions & 1 deletion index.js

This file was deleted.

63 changes: 63 additions & 0 deletions index2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
function validatePassword (password) {
var charCount = (password.length >= 8)
var checkUpCase = true
var charLength = true
var charLowCase = true
var charNumVal = true
var specCharVal = true



var upperCase = /[A-Z]/
var lowerCase = /[a-z]/
var numValue = /[0-9]/
var specChar = /[!@#&*._]/


if (charCount) {
charLength = true
} else {
charLength = false
}


if (upperCase.test(password)) {
checkUpCase = true

} else {
checkUpCase = false
}

if (lowerCase.test(password)) {
charLowCase = true

} else {
charLowCase = false
}

if (numValue.test(password)) {
charNumVal = true

} else {
charNumVal = false
}

if (specChar.test(password)) {
specCharVal = true
} else {
specCharVal = false

}

var passwordValidator = checkUpCase == true && charLength == true && charLowCase == true && charNumVal == true && specCharVal == true
if (passwordValidator) {
passwordValidator = true
} else {
passwordValidator = false
}
return passwordValidator


}

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
2 changes: 1 addition & 1 deletion test/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { expect } = require('chai')
const validatePassword = require('../index')
const validatePassword = require('../index2')

describe('validatePassword', () => {
it('returns true when the password meets all requirements', () => {
Expand Down