Skip to content

Latest commit

 

History

History
58 lines (48 loc) · 1.14 KB

isCreditCardNumber.md

File metadata and controls

58 lines (48 loc) · 1.14 KB

piupiu.isCreditCardNumber(input)

Return true if input is a valid credit card number. If not, return false.

Source

Description

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.

Since

0.1.0

Arguments

input (string)

Returns

(boolean): Returns true if the input is a valid credit card number.

Example

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