From 1ba8730cca5b41cabaef2bf32bcb4d5411fb670e Mon Sep 17 00:00:00 2001 From: Prasanna Date: Thu, 9 Jul 2020 21:33:32 -0400 Subject: [PATCH 1/2] Password Validator Completed --- index.js | 1 - index2.js | 63 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 +- test/index.spec.js | 2 +- 4 files changed, 65 insertions(+), 3 deletions(-) delete mode 100644 index.js create mode 100644 index2.js diff --git a/index.js b/index.js deleted file mode 100644 index a72e7e6..0000000 --- a/index.js +++ /dev/null @@ -1 +0,0 @@ -// Do work! \ No newline at end of file diff --git a/index2.js b/index2.js new file mode 100644 index 0000000..acb6053 --- /dev/null +++ b/index2.js @@ -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 \ No newline at end of file diff --git a/package.json b/package.json index 21c8e3e..9c31e06 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "scripts": { "lint": "eslint --format codeframe .", "lint:fix": "eslint --fix --format codeframe .", - "test": "mocha -w" + "test": "mocha" }, "repository": { "type": "git", diff --git a/test/index.spec.js b/test/index.spec.js index e9cf47f..5df3dab 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -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', () => { From 8e97dceab201da4c8aef64191d8fbc20a3f45d2c Mon Sep 17 00:00:00 2001 From: Prasanna Date: Mon, 13 Jul 2020 20:18:36 -0400 Subject: [PATCH 2/2] Response --- index2.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/index2.js b/index2.js index acb6053..8968397 100644 --- a/index2.js +++ b/index2.js @@ -1,10 +1,10 @@ function validatePassword (password) { var charCount = (password.length >= 8) - var checkUpCase = true; - var charLength = true; - var charLowCase = true; - var charNumVal = true; - var specCharVal = true; + var checkUpCase = true + var charLength = true + var charLowCase = true + var charNumVal = true + var specCharVal = true