abadi199/elm-creditcard/1.0.1

NOTE: this package is not compatible with Elm 0.19.1

CreditCard.Model

Model types and all related helper functions

Model

type alias Model msg =
{ options : Options
, number : Field Int
, name : Field String
, expirationMonth : Field Int
, expirationYear : Field Int
, ccv : Field Int
, cardInfo : Maybe (CardInfo msg)
, flipped : Maybe Bool
}

A type representing the Credit Card model.

type alias Field a =
{ id : String
, label : Maybe String
, value : Maybe a
, hasFocus : Bool
}

A type representing an input field with specific type.

type alias Styles msg =
{ cardStyle : CardStyle msg }

A type representing the form style.

type alias CardInfo msg =
{ cardType : CardType
, validLength : List Int
, numberFormat : NumberFormat
, cardStyle : CardStyle msg
, ccvPosition : CCVPosition
}

A type representing the card information.

= Unknown
| Visa
| Mastercard
| Amex
| Discover
| DinersClubCarteBlanche
| DinersClubInternational
| JCB
| Laser
| Maestro
| VisaElectron

A union type representing the credit card type.

Styling and Formatting

type alias Options =
{ showLabel : Bool
, blankChar : Char
}

A type representing the configurable options for the form.

type alias CardStyle msg =
{ background :
{ attributes : List (Attribute msg)
, svg : List (Svg msg)
, defs : List (Svg msg)
}
, textColor : String
, lightTextColor : String
, darkTextColor : String
}

A type representing the card style.

= Front
| Back

A union type representing the position of the CCV

type alias NumberFormat =
List Int

A type representing the format of the number by specifying the size of each group. e.g: [4, 4, 5] will format the number to be XXXX XXXX XXXXX

Helper Functions

init : Model msg

init function