JamesEggers1 / luhn

A JavaScript module of the luhn algorithm for Credit Card Validation that works with both client-side JavaScript and Node.js
MIT License
52 stars 17 forks source link

Return true when the card number is zero, wtf ? #14

Closed mel-florance closed 6 years ago

mel-florance commented 7 years ago

As in the title, the function returns true with a card number of zero, (or multiple zeros).

I dont know what to think, it look like a major issue.

I didnt search further in the library code to find a solution yet, but soon i'll try.

JamesEggers1 commented 6 years ago

This issue is how the checksums are calculated. Since the validation algorithm adds the digits and multiples of the digits together and then checks that it's divisible by 10, a sum of 0 would pass the validation.

I'll add tests and a validation to test that the summation of algorithm isn't 0.

JamesEggers1 commented 6 years ago

This is now fixed in v2.3.0 of the package.