Credit Card format validation
If available in Hex, the package can be installed
by adding cc_validation
to your list of dependencies in mix.exs
:
def deps do
[{:cc_validation, "~> 0.1.0"}]
end
Valid credit card
iex> CcValidation.validate("4716892095589823")
{:ok, true}
Invalid credit card
iex> CcValidation.validate("4024007106963124")
{:error, false}
Test card returns false
iex> CcValidation.validate("4111111111111111")
{:error, false}
A valid test card
iex> CcValidation.validate("4111111111111111", true)
{:ok, true, test_number: true}
An invalid test card
iex> CcValidation.validate("4212121212121212", true)
{:error, false, test_number: false}
A valid card when checking for test numbers just passes through to the validate function but will also return that it is not a test card
iex> CcValidation.validate("4716892095589823", true)
{:ok, true, test_number: false}
iex> CcValidation.validate("123")
{:error, false}
iex> CcValidation.validate("12345678901234567890")
{:error, false}
Tests can be ran with mix
by running mix test
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/cc_validation.