/

Validating Text and Managing the Editing Process

VGSConfiguration adds more power to your VGSTextField. Its' attributes are used to connect VGSTextField with specific VGSCollect instance, perform built-in validations and add additional features.

VGS Configuration

Declaration

class VGSConfiguration
This is a sample VGS echo server
This is a login from access credentials
This is a password from access credentials
This is a HTTP port number to access
This is a  sample VGS alias  in a generic format
This is a sample test  vault id
This is a username/password pair of  access credentials  for a sample test vault
This is a sample  vault url, that contains the vault id and the sandbox environment
This is a sample  vault host,  which contains sample test vault id and sandbox environment
This is a current Organization ID
This is a current vault id
The unique name that identifies a specific iframe
This is a  sample VGS alias  in a generic format

Creating a VGSConfiguration

init(collector vgs: VGSCollect, fieldName: String)
This is a sample VGS echo server
This is a login from access credentials
This is a password from access credentials
This is a HTTP port number to access
This is a  sample VGS alias  in a generic format
This is a sample test  vault id
This is a username/password pair of  access credentials  for a sample test vault
This is a sample  vault url, that contains the vault id and the sandbox environment
This is a sample  vault host,  which contains sample test vault id and sandbox environment
This is a current Organization ID
This is a current vault id
The unique name that identifies a specific iframe
This is a  sample VGS alias  in a generic format

VGSConfiguration attributes

AttributeDescription
fieldNameIdentifier for Redact/Reveal operations on Inbound/Outbound routes
isRequiredMark the field should be non-empty and non-nil on VGSCollect.sendData(_:) request. Default is false
isRequiredValidOnlyMark the field should be valid on VGSCollect.sendData(_:). Default is false
typeFieldType used to define default field validation and formatting
formatPatternInput text mask pattern. If not set, will be used default masking for each FieldType
dividerDivider string replace spaces or other characters in input string based on formatPattern. Replacement will be done during sendData(_:) request.
keyboardTypeRequests that a particular keyboard type be displayed when a textfield becomes first responder. If not set, will be used default keyboardType for each FieldType
returnKeyTypeKeyboard return key
keyboardAppearanceKeyboard Appearance Type, default is UIKeyboardAppearance.default
validationRulesA set of rules that will be applied for input validation. If nil, default validation rules will be applied

Some of VGSConfiguration attribites are used to create rules for input data validation. You can check validation results represented in a State object.

Note
• When FieldType is not none, default validation will be applied to input data.
• When isRequired set as true, input data is empty or nil - VGSCollect.sendData(_:) request will return error.
• When isRequiredValidOnly set as true, input data is not valid - VGSCollect.sendData(_:) request will return error.
• For .expCardDate FieldType default divider is / character and for .ssn type is - character. For other FieldTypes it's empty string.

VGSConfiguration FieldType

FieldTypeDescription
.cardNumber
- input field for the card number
- validation: Luhn valid cards
.cvc
- input field for card security code
- validation: 3-4 symbols, numbers only
.expDate
- input field for the card expiration date
- validation: future date in mm/yy or mm/yyyy formats
.cardHolderName
- input field for cardHolderName
- validation: ascii letters, at least 2 characters
.ssn
- input field for US Social Security Number
- validation: 9 symbols, numbers only
.none
- input field for any type of data, you can put anything to it
- validation: none

If you didn't find specific FieldType for your use case, you can always configure VGSTextField with VGSConfiguration.fieldType = .none. Then assign any specific rule set to the field and use other configuration attributes.

VGSConfiguration formatPattern

The formatPattern string string will be applied as a mask on the user input text. It also works as input characters filter.
This pattern can be used only for visual input format in VGSTextField. It doesn't have an impact on input data format when you send it to VGS. In case you need to send data with additional characters, check the Divider section.

FormatDescriptionExample
*Letters and Digits replacement char"UA12345vgs"**-***"UA-123"
@Any letter replacement char"UA12345vgs"@@_@@@"UA_vgs"
aLowercase replacement char"UA12345vgs"aaa"vgs"
AUppercase replacement char"UA12345vgs"AAA"UA"
#Digits replacement char"UA12345vgs"#/##/##"1/23/45"
Limitations
• You can only use non-alphaNumeric characters as dividers in the formatPattern string.
• The formatPattern will not be applied to the .cvc FieldType.
• For the .expCardDate FieldType it is only allowed to set date format as ##/## or ##/#### (that will represent MM/YY or MM/YYYY format). In other cases, the field validation State will fail.

VGSConfiguration Divider

Use the divider if you need to replace characters in the input text. Characters will be replaced based on formatPattern when data are being sent to VGS.

Examples

// ...

/// Example 1
configuration.formatPattern = "#### #### #### ####"
configuration.divider = "-"

user input: "4111111111111111"
textfield format: "4111 1111 1111 1111"
sending format: "4111-1111-1111-1111"

/// Example 2
configuration.formatPattern = "##/##/##"
configuration.divider = ":"

user input: "122030"
textfield format: "12/20/30"
sending format: "12:20:30"

// Example 3
configuration.formatPattern = "**-***"
configuration.divider = "//"

user input: "UA123"
textfield format: "UA-123"
sending format: "UA//123"

This is a sample VGS echo server
This is a login from access credentials
This is a password from access credentials
This is a HTTP port number to access
This is a  sample VGS alias  in a generic format
This is a sample test  vault id
This is a username/password pair of  access credentials  for a sample test vault
This is a sample  vault url, that contains the vault id and the sandbox environment
This is a sample  vault host,  which contains sample test vault id and sandbox environment
This is a current Organization ID
This is a current vault id
The unique name that identifies a specific iframe
This is a  sample VGS alias  in a generic format
Note
• If formatPattern is empty string, then divider will be not applied.

For more details about available attributes and functionality check VGSCollectSDK Reference docs.