This library allows validation of a creditcard number potentially limiting by accepted card types. For example, if your business only accepts Mastercard and Visa you can limit the valid cards to those types.
Card types supported by this library are: American Express (AM), Discover (DS), Diners Club (DC), Mastercard (MC) and VISA (VI).
{ name : String
, cardType : CardType
, bins : List Range
, valid_lengths : List Basics.Int
}
String
{ card_types : List (Maybe CardTypeInfo)
, valid : Basics.Bool
, luhn_valid : Basics.Bool
, length_valid : Basics.Bool
, cardTypeValid : Basics.Bool
}
A card number can match multiple card types. Overall, a number is valid when it's valid according to luhn algorithm with valid length and type.
Represents possible ranges for a creditcard number. It can be a string or a range with starting and ending digits
validate : String -> List CardType -> ValidationResult
Find whether a creditcard number is valid. You can limit what card types are eligible for the validation attempt.
mopToCardType : String -> CardType
Converts from string MOP (Method of Payment) to CardType
validCardLength : CardTypeInfo -> CreditCardNumber -> Basics.Bool
Finds whether card length is one of the valid lengths for the type
findNumberInBetweenRange : CreditCardNumber -> String -> String -> Basics.Bool
allCardTypes : List CardTypeInfo
List of CardTypeInfo for all supported types
cardTypeByBinRange : CreditCardNumber -> List CardTypeInfo -> Maybe CardTypeInfo
Find card info whose ranges contain a pattern that the card number matches
numberInStartsWithRange : String -> String -> Basics.Bool
cardMatchesRange : CreditCardNumber -> List Range -> Basics.Bool
filterByCardTypes : List CardTypeInfo -> List CardType -> List CardTypeInfo
toCleanCCNumber : String -> CreditCardNumber