String

struct String
  • String by stripping all whitespaces

    Declaration

    Swift

    public var strippedWhitespaces: String
  • String by stripping all non-digit characters

    Declaration

    Swift

    public var stripped: String
  • String by stripping commas

    Declaration

    Swift

    public var strippedCommas: String
  • Method to check if a string is Luhn valid

    Declaration

    Swift

    public func isLuhnValid() -> Bool

    Return Value

    true if given string is Luhn valid

  • Method to check whether string contains only numbers and letters

    Declaration

    Swift

    public func isAlphaNumeric() -> Bool

    Return Value

    true if string consists of numbers and letters

  • Method to check whether string contains only numbers and letters

    Declaration

    Swift

    public func isNumeric() -> Bool

    Return Value

    true if string consists of numbers and letters

  • Returns a string that matches the format of the number on the card itself based on the spacing pattern

    Parameter

    Parameter configurations: The valid configurations to check for when

    Returns

    A formatted String that matches the credit card format

    Throws

    Throws CardLengthMismatchError: If amount of characters is longer than the maximum character number

    Throws

    Throws InvalidCardNumber: If the card number is invalid

    Declaration

    Swift

    func cardPresentationString(configurations: [Card.Configuration]) throws -> String

    Parameters

    configurations

    The valid configurations to check for when

    Return Value

    A formatted String that matches the credit card format

  • See https://en.wikipedia.org/wiki/Bank_card_number This method will not do any validation - just a check for numbers from at least 1 character and return an assumption about what the card might be.

    Parameter

    Parameter configurations: Only return valid responses for the given configurations

    Returns

    CardNetwork object

    Declaration

    Swift

    func cardNetwork(constrainedToConfigurations configurations: [Card.Configuration]) -> CardNetwork?

    Parameters

    configurations

    Only return valid responses for the given configurations

    Return Value

    CardNetwork object

  • See https://en.wikipedia.org/wiki/Bank_card_number This method will not do any validation - just a check for numbers from at least 1 character and return an assumption about what the card might be.

    Returns

    CardNetwork object

    Declaration

    Swift

    func cardNetwork() -> CardNetwork

    Return Value

    CardNetwork object

  • Check if the string is representing a valid credit card number

    Returns

    True if the string is a valid credit card number

    Declaration

    Swift

    func isCardNumberValid() -> Bool

    Return Value

    True if the string is a valid credit card number