Validating Text and Managing the Editing Process



class VGSConfiguration

Creating a VGSConfiguration

init(collector vgs: VGSCollect, fieldName: String)

VGSConfiguration attributes

VGSConfiguration FieldType

FieldType Description
- input field for the card number
- validation: Luhn valid cards
- input field for card security code
- validation: 3-4 symbols, numbers only
- input field for the card expiration date
- validation: future date in mm/yy format
- input field for cardHolderName
- validation: non-empty field
- input field for any type of data, you can put anything to it
- validation: none

VGSConfiguration formatPattern

The formatPattern string will be applied as mask on user input text. It also works as input characters filter.

Format Description Example
* Letters and Digits replacement char “UA12345vgs” **-*** “UA-123”
@ Any letter replacement char “UA12345vgs” @@_@@@ “UA_vgs”
a Lowercase replacement char “UA12345vgs” aaa “vgs”
A Uppercase replacement char “UA12345vgs” AAA “UA”
# Digits replacement char “UA12345vgs” #/##/## “1/23/45”


  • The formatPattern mask will be applied to any FieldType by default. To change it you can set your own formatPattern.
  • If formatPattern is empty string - no mask will be applied to input text.
  • You only allowed setting non-alphaNumerical characters as dividers in formatPattern string.
  • Input text will be sent to backend without mask.



protocol VGSTextFieldDelegate

Managing VGSTextField states

/// VGSTextField did become first responder
optional func vgsTextFieldDidBeginEditing(_ textfield: VGSTextField)

/// VGSTextField did resign first responder
optional func vgsTextFieldDidEndEditing(_ textfield: VGSTextField)

/// VGSTextField did resign first responder on Return button pressed
optional func vgsTextFieldDidEndEditingOnReturn(_ textfield: VGSTextField)

VGSTextField UIResponder methods

/// Returns a Boolean value indicating whether this object is the first responder
var isFirstResponder: Bool

/// Asks UIKit to make this object the first responder
@discardableResult func becomeFirstResponder() -> Bool

/// Asks UIKit to resign this object as first responder
@discardableResult func resignFirstResponder() -> Bool