CardValidation
public struct CardValidation
Create card validations.
-
Supported card brands.
Declaration
Swift
public var acceptedCardBrands: [CardBrand]
-
Expiration date validation.
Declaration
Swift
public var expirationDateValidation: TextValidation
-
Cardholder name validation.
Declaration
Swift
public var nameOnCardValidation: TextValidation
-
Zip code validation.
Declaration
Swift
public var postalCodeValidation: TextValidation
-
Card validations constructor.
Declaration
Swift
public init( acceptedCardBrands: [CardBrand] = CardBrand.allBrands, expirationDateValidation: TextValidation = TextValidation( regex: "[0-9][0-9]/[0-9][0-9]", minimumCharacters: 5, maximumCharacters: 5, isRequired: true), nameOnCardValidation: TextValidation = TextValidation( regex: nil, minimumCharacters: 0, maximumCharacters: .max, isRequired: false), postalCodeValidation: TextValidation = TextValidation( regex: "^[0-9]+$", minimumCharacters: 5, maximumCharacters: 5, isRequired: true))
Parameters
acceptedCardBrands
Supported card brands. Defaults to
CardBrand.allBrands
.expirationDateValidation
Expiration date validation. Defaults to \d{2}/\d{2} regex with minimum and maximum characters of 5 and required.
nameOnCardValidation
Cardholder name validation. Defaults to no regex, minimum 0 characters and maximum of
UInt.max
and not required.postalCodeValidation
Zip/Postal code validation. Defaults to ^\d+$ regex with minimum and maximum characters of 5 and required.
-
Default configuration to disable all validations.
Declaration
Swift
public static func disabledValidation() -> CardValidation
Return Value
CardValidation
instance. -
Card number validation.
Declaration
Swift
public func panValidation(for cardBrand: CardBrand) -> TextValidation
Parameters
cardBrand
CardBrand
case.Return Value
CardValidation
model. -
CVV/CVC validation.
Declaration
Swift
public func securityCodeValidation(for cardBrand: CardBrand) -> TextValidation
Parameters
cardBrand
CardBrand
case.Return Value
TextValidation
model.