generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 315
London|26-ITP-January|Alexandru Pocovnicu|Sprint 3 |stretch #951
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
alexandru-pocovnicu
wants to merge
18
commits into
CodeYourFuture:main
Choose a base branch
from
alexandru-pocovnicu:coursework/sprint-3-stretch
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
ad58383
wrote password validation tests to check if the password includes num…
alexandru-pocovnicu 8bc912e
implemented password validation function
alexandru-pocovnicu 88e7a16
Add card validator implementation and tests from sprint-3-implement-a…
alexandru-pocovnicu 244ef86
tested for card number length
alexandru-pocovnicu 5658bec
Refactor card validation tests for accuracy and completeness
alexandru-pocovnicu 04e0b3f
Implement card number validation logic
alexandru-pocovnicu 3c7e3ca
Refactor card number validation function for improved readability
alexandru-pocovnicu e045c33
changed variable declaration method
alexandru-pocovnicu 2fbf4b6
updated tests descriptions for better understanding
alexandru-pocovnicu 9462c1f
refactored for improved performance
alexandru-pocovnicu f78f11b
updated tests description
alexandru-pocovnicu 74c180e
updated test for password length
alexandru-pocovnicu ea25ca5
added test to reject previously used passwords
alexandru-pocovnicu 55f0ccc
enhanced passwordValidator to check against previously used passwords
alexandru-pocovnicu 2be0512
updated tests descriptions
alexandru-pocovnicu 3e9b0ba
updated tests descriptions
alexandru-pocovnicu f266cbe
updated tests to check if the password was used before or not
alexandru-pocovnicu 6e5099c
updated tests descriptons
alexandru-pocovnicu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| function validateNumber(number) { | ||
| const arrNumber = [...number.toString()]; | ||
|
|
||
| return arrNumber.length === 16 && | ||
| arrNumber.every((x) => x >= "0" && x <= "9") && | ||
| new Set(arrNumber).size > 1 && | ||
| arrNumber[arrNumber.length - 1] % 2 === 0 && | ||
| arrNumber.reduce((acc, cur) => +acc + +cur, 0) > 16 | ||
| ? true | ||
| : false; | ||
| } | ||
|
|
||
| module.exports = validateNumber; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| const validateNumber = require("./card-validator"); | ||
| const isValidNumber = require("./card-validator"); | ||
|
|
||
| test("returns true for a 16-digit number", () => { | ||
| expect(validateNumber(1029384756820562)).toEqual(true); | ||
| }); | ||
| test("should return false if the number is less than 16 digits", () => { | ||
| expect(validateNumber(10293847568202)).toEqual(false); | ||
| }); | ||
| test("should return false if the number is more than 16 digits long", () => { | ||
| expect(validateNumber(1029384756820512348)).toEqual(false); | ||
| }); | ||
|
|
||
| test("returns true when all characters are digits", () => { | ||
| expect(validateNumber(1036294650361848)).toEqual(true); | ||
| }); | ||
| test("should return false if one or more of the digits aren't numbers", () => { | ||
| expect(validateNumber("103629465036184a")).toEqual(false); | ||
| }); | ||
|
|
||
| test("returns true when digits are not all identical", () => { | ||
| expect(validateNumber(3636363636363636)).toEqual(true); | ||
| }); | ||
| test("returns true when one digit differs", () => { | ||
| expect(validateNumber(3333333333333336)).toEqual(true); | ||
| }); | ||
| test("returns false when all digits are identical", () => { | ||
| expect(validateNumber(2222222222222222)).toEqual(false); | ||
| }); | ||
|
|
||
| test("should return true if the final digit is even", () => { | ||
| expect(validateNumber(1528056378293456)).toEqual(true); | ||
| }); | ||
| test("should return false if the final digit isn't even", () => { | ||
| expect(validateNumber(1528056378293457)).toEqual(false); | ||
| }); | ||
|
|
||
| test("should return true if the sum of all digits is greater than 16", () => { | ||
| expect(validateNumber(1903647295628592)).toEqual(true); | ||
| }); | ||
| test("should return false if the sum of all the digits isn't greater than 16", () => { | ||
| expect(validateNumber(1000100000000002)).toEqual(false); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,16 @@ | ||
| function passwordValidator(password) { | ||
| return password.length < 5 ? false : true | ||
| } | ||
| function passwordValidator(password,oldPasswords=[]) { | ||
| if ( | ||
| /[A-Z]/.test(password) && | ||
| /[a-z]/.test(password) && | ||
| /[0-9]/.test(password) && | ||
| /[!#$%.*&]/.test(password) && | ||
| password.length >= 5 && | ||
| !oldPasswords.includes(password) | ||
| ) | ||
| return true; | ||
|
|
||
|
|
||
| return false; | ||
| } | ||
|
|
||
| module.exports = passwordValidator; | ||
| module.exports = passwordValidator; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.