The performed check is overly stringent (and sometimes wrong) regarding the accepted formats. The following illustrates two cases derived from this site.
> const validator = require('validator');
> validator.isCreditCard('4716967026053481241') // OK; Visa
true
> validator.isCreditCard('6396827370876380') // Not OK; Maestro
false
> validator.isCreditCard('5020198842623966') // No OK; InstaPayment
false
More details on number formats are available here, here, and here. I think the correct validation approach would be to check the length of known issuer identification numbers (IINs) and for the rest, accept numbers with 12–19 digits that have a valid Luhn checksum. I'll try to provide a fix, and would welcome any comments regarding this approach.
The performed check is overly stringent (and sometimes wrong) regarding the accepted formats. The following illustrates two cases derived from this site.
More details on number formats are available here, here, and here. I think the correct validation approach would be to check the length of known issuer identification numbers (IINs) and for the rest, accept numbers with 12–19 digits that have a valid Luhn checksum. I'll try to provide a fix, and would welcome any comments regarding this approach.