DSInputMask

public protocol DSInputMask

Represents the configuration of a DSTextField that handles the type of keyboard it uses as well as what’s allowed to be typed.

  • Declaration

    Swift

    var keyboardType: UIKeyboardType? { get }
  • Returns the raw text in the field, minus all formatting symbols

    Declaration

    Swift

    func rawText(from text: String) -> String
  • Returns true if the text being entered, the replacementString, and the resulting string are allowable. If there are invalid characters in either, false should be returned.

    Declaration

    Swift

    func shouldAllow(replacementString string: String, resultingString: String) -> Bool

    Parameters

    replacementString

    The text that was added to the text

    resultingString

    The completed text as it would appear after replacement

    Return Value

    True if the text should be allowed

  • Returns a formatted version of originalText.

    Declaration

    Swift

    func applyFormattingMask(to originalText: String) -> String

    Parameters

    to

    Raw, original text that should be formatted. (e.g., 3035551234)

    Return Value

    Formatted text. (e.g., 303-555-1234)