EnterpriseDS Documentation

Structure DSCredit​Card

public struct DSCreditCard  

A credit card that identifies properties of various brand types, performs validation, and can perform formatting of their numbers.

let creditCard = DSCreditCard(number: "4111111111111111")

print(creditCard.isValid)
print(creditCard.formattedNumber)

Initializers

init(number:​)

public init(number: String)  

Initializes and returns a newly allocated CreditCard based on the number.

Parameters

number String

A credit card number

Properties

card​Type

public private(set) var cardType: DSCreditCardType

The type of credit card, identified as best as possible, based on a number.

number

public private(set) var number: String

The raw credit card number.

is​Valid

public var isValid: Bool  

Returns true if the card number's brand is identifiable, and valid to those constraints, or if the brand is not identified and has a length greater than 0.

formatted​Number

public var formattedNumber: String  

Returns the properly formatted card number if its brand is identified. (e.g. Visa, Mastercard, etc.)