View Source Appwrite.Consts.CreditCard (appwrite v0.1.9)
Provides constants and validation functions for different credit card types.
This module defines the allowed credit card types and provides helper functions to validate them, ensuring only recognized credit card types are used within the application.
Summary
Functions
Returns true
if the given credit_card
type is valid, otherwise false
.
Guard clause to check if a given credit card type is valid.
Validates the given credit_card
type and returns {:ok, credit_card}
if it is valid,
or {:error, "Invalid credit card type"}
otherwise.
Validates the given credit_card
type and returns it if it is valid. Raises an
ArgumentError
if the credit_card
type is invalid.
Functions
Returns true
if the given credit_card
type is valid, otherwise false
.
Examples
iex> CreditCard.is_valid_credit_card?("mastercard")
true
iex> CreditCard.is_valid_credit_card?("unknown")
false
Guard clause to check if a given credit card type is valid.
Examples
iex> CreditCard.valid_credit_card("amex")
true
iex> CreditCard.valid_credit_card("unknown")
false
Validates the given credit_card
type and returns {:ok, credit_card}
if it is valid,
or {:error, "Invalid credit card type"}
otherwise.
Examples
iex> CreditCard.validate_credit_card("amex")
{:ok, "amex"}
iex> CreditCard.validate_credit_card("unknown")
{:error, "Invalid credit card type"}
Validates the given credit_card
type and returns it if it is valid. Raises an
ArgumentError
if the credit_card
type is invalid.
Examples
iex> CreditCard.validate_credit_card!("visa")
"visa"
iex> CreditCard.validate_credit_card!("unknown")
** (ArgumentError) Invalid credit card type: "unknown"