Return true if input is a valid credit card number. If not, return false.
We perform some basic checks, input string :
- must contains only numeric value ;
- is of between 13 and 19 digits ;
- And finally perform a luhn check to ensure that the credit card number is a valid one.
0.1.0
input (string)
(boolean)
: Returns true
if the input is a valid credit card number.
piupiu.isCreditCardNumber('4816089253950827');
// true
piupiu.isCreditCardNumber('4816 0892 5395 0827');
// false
piupiu.isCreditCardNumber('qededq');
// false
piupiu.isCreditCardNumber(0);
// false
piupiu.isCreditCardNumber(undefined);
// false
piupiu.isCreditCardNumber({});
// false
piupiu.isCreditCardNumber([]);
// false
piupiu.isCreditCardNumber(NaN);
// false