Module: CreditCardValidator

Defined in:
lib/credit_card_validator.rb,
lib/credit_card_validator/validator.rb

Defined Under Namespace

Classes: Validator

Constant Summary collapse

VERSION =
'1.3.2'
CARD_TYPES =
{
  :visa => /^4[0-9]{12}(?:[0-9]{3})?$/,
  :master_card => /(?:^5[1-5]\d{14}$)|(?:^2(?:2(?:2[1-9]|[3-9]\d)\d{2}|[3-6]\d{4}|7(?:[01]\d{3}|20\d{2}))\d{10}$)/,
  :maestro => /(^6759[0-9]{2}([0-9]{10})$)|(^6759[0-9]{2}([0-9]{12})$)|(^6759[0-9]{2}([0-9]{13})$)/,
  :diners_club => /^3(?:0[0-5]|[68][0-9])[0-9]{11}$/,
  :amex => /^3[47][0-9]{13}$/,
  :discover => /^6(?:011|5[0-9]{2})[0-9]{12}$/,
  :jcb => /^(?:2131|1800|35\d{3})\d{11}$/
}
TEST_NUMBERS =
{
  :amex => %w{
    378282246310005 371449635398431 378734493671000 },
  :diners_club => %w{
    30569309025904 38520000023237 },
  :discover => %w{
    6011000990139424 6011111111111117 },
  :master_card => %w{
    2223000048400011 2223520043560014 5555555555554444
    5105105105105100 },
  :visa => %w{
    4111111111111111 4012888888881881 4222222222222
    4005519200000004 4009348888881881 4012000033330026
    4012000077777777 4217651111111119 4500600000000061
    4000111111111115 },
  :jcb => %w{
    3530111333300000 3566002020360505
  }
}.values.flatten