asaskevich / govalidator

[Go] Package of validators and sanitizers for strings, numerics, slices and structs
MIT License
6.02k stars 556 forks source link

Test iscreditcard #355

Closed lfaoro closed 4 years ago

lfaoro commented 4 years ago

Improving the IsCreditCard validation tests by adding more card brands, which reveals some card brands won't pass our validation logic.

        // below should be valid, do they respect international standards?
        // is our validator logic not correct?
        {"diners club international", "30190239451016", false,},
        {"rupay", "6521674451993089", false,},
        {"mir", "2204151414444676", false,},
        {"china unionPay", "624356436327468104", false,},

Sorry about all the whitespace changes, it appears the file wasn't gofmt'ed. My changes start at L:1392: https://github.com/asaskevich/govalidator/compare/master...lfaoro:test-iscreditcard?expand=1#diff-bf215ece4e5166da723b1e19a0d6b1cdR1392

The cards are generates from: https://ccard-generator.com/bulk-generate/visa

asaskevich commented 4 years ago

https://ccard-generator.com/bulk-generate/visa conflicting with https://www.validcreditcardnumber.com which is saying that added cards is not valid due to Luhn Algorithm

asaskevich commented 4 years ago

I've added tests and merged, but we need some investigation about https://ccard-generator.com/bulk-generate/visa

Looks like cards generated by this site don't follow default Luhn algorithm used to ensure that checksum is not broken.