maxkramer / SwiftLuhn

Debit/Credit card validation port of the Luhn Algorithm in Swift
MIT License
135 stars 27 forks source link

JCB cards incorrectly validated #10

Open ssathy2 opened 6 years ago

ssathy2 commented 6 years ago

A few resources (https://www.cybersource.com/developers/getting_started/test_and_manage/best_practices/card_type_id/, https://www.freeformatter.com/credit-card-number-generator-validator.html, https://en.wikipedia.org/wiki/Payment_card_number) on credit card validation mention that JCB cards have IIN ranges of 3528–3589. Currently, the regex that the library to validate JCB cards is "^(?:2131|1800|35[0-9]{3})[0-9]{3,}$". This means that a card starting with 3510 will get validated as a JCB card.

maxkramer commented 6 years ago

@ssathy2 thanks for the issue, sorry it's taken this long to get to it. Do you have a regex that would fulfil this condition? ^35[0-9]{2}([0-9]{12}|[0-9]{15})$ would come close