-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Credit card validation #924
Conversation
implemented Luhn algoritm to validate credit card string
baked_in.go
Outdated
|
||
ccDigits := strings.Split(creditCard.String(), "") | ||
size := len(ccDigits) | ||
if size < 14 || size > 16 { |
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.
Globally, card numbers (PAN) can be 12 - 19 digits
(see https://en.wikipedia.org/wiki/Payment_card_number)
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.
@marrow16 thank you for pointing out the min and max size of a PAN. I've updated the code according to the documentation that you provided.
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.
@marrow16 @alessmar
Hi folks,
Actually PAN length is in range 10-19
IIN length has been extended to 8-digits in fifth edition of ISO/IEC 7812 published in 2017[[2]](https://en.wikipedia.org/wiki/Payment_card_number#cite_note-2) and PAN will continue to remain variable length, ranging from 10 to 19 digits.
|
||
ccDigits := strings.Split(creditCard.String(), "") | ||
size := len(ccDigits) | ||
if size < 12 || size > 19 { |
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.
Hi,
I wrote this comment below the previous comments' thread.
However just in case putting it also here
The correct PAN validation nowadays should be size < 10 || size > 19
Here is the official statement:
https://www.iso.org/news/2016/11/Ref2146.html
Within the current version of ISO/IEC 7812-1, an IIN is defined as a fixed-length numeric of six digits. The standard also defines the Primary Account Number (PAN), a number which is used to identify an individual account holder. The PAN is of variable length, ranging from 8 to 19 digits.
Due to the increasing number of card issuers
, there is expected to be a shortage in the available supply of IINs. Therefore, ISO/IEC 7812-1 is being revised
to expand the IIN to an eight-digit numeric value from the current six digits. The PAN will continue to remain a variable length, ranging from 10 to 19 digits.
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.
👍
Implemented Luhn algoritm to validate credit card string
Fixes Or Enhances
Make sure that you've checked the boxes below before you submit PR:
@go-playground/validator-maintainers