cnum v0.1.0 Cnum

Cnum provides categorization and verification methods for a credit card number.

Link to this section Summary

Functions

Returns the brand of a given card number.

Returns true if the given card number is valid or if the number is a test card number.

Link to this section Functions

Link to this function

type(pan)

type(any()) :: binary()

Returns the brand of a given card number.

Currently supported brands:

  • AmericanExpress
  • DinersClub
  • Discover
  • Jcb
  • Maestro
  • MasterCard
  • Visa
  • VisaElectron

Parameters

  • pan: Integer or String that represents the primary account number on a payment card.

Examples

iex> Cnum.type(4111111111111111)
"visa"

iex> Cnum.type("3400 0000 0000 009")
"amex"

iex> Cnum.type("1404 0092 0000 0004")
"unknown"
Link to this function

valid?(pan)

valid?(any()) :: boolean()

Returns true if the given card number is valid or if the number is a test card number.

Test credit card numbers are valid by default.

Parameters

  • pan: Integer or String that represents the primary account number on a payment card.

Examples

iex> Cnum.valid?("3400 0000 0000 009")
true

iex> Cnum.valid?(55555555555544)
false

iex> Cnum.valid?("")
false