-
Notifications
You must be signed in to change notification settings - Fork 82
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
fix: fixing isValid method #152
Open
davidalves1
wants to merge
1
commit into
ContaAzul:master
Choose a base branch
from
davidalves1:fix/isValid-method
base: master
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
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 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot define that the card number must have 16 digits. For example AMEX has 15 digits, and some others up to 19, and sometimes 13.
https://www.pcidssguide.com/what-do-the-credit-card-numbers-mean/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, so following this article and the others bellow, the range of credit card number length is 12 to 19, right?!
In this way, I believe it is possible to define this range to avoid errors like the one described in the issue. What do you think?
https://www.discoverglobalnetwork.com/content/dam/discover/en_us/dgn/docs/IPP-VAR-Enabler-Compliance.pdf
https://www.forbes.com/advisor/credit-cards/what-does-your-credit-card-number-mean/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I evaluated the list of supported cards and added the number of digits for each one:
American Express (15 digits)
Aura (19 digits)
Banescard (16 digits)
Cabal (16 digits)
Diners (14 digits)
Discover (16 digits)
Elo (16 digits)
Goodcard (16 digits)
Hipercard (16 digits)
Mastercard (16 digits)
Maxxvan (16 digits)
Visa (16 digits)
With this we can conclude that the cards must have between 14 and 19 digits.
What do you think of we add a "cardNumberLenght" property to each card in cards.js and create a method to check the minimum and maximum number of digits for a valid card? This way we avoid adding the number manually in the
isValid
method.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally agree, looks like a good way. I can close this PR and open another one with this implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is exactly why i did in another version :) and why in the public release i don't validate by length