Browse
 
Tools
Rss Categories

Advanced validation

Reference Number: AA-00324 Last Updated: 2016-07-27 14:01

By using the Match constraint you can validate inputs against patterns or so-called "regular expressions". Validation operators offer predefined regular expressions which represent common algorithms or formats.

Regular expressions use a powerful syntax which you can use to build very complex patterns. See the cheat sheet at the bottom of this article ("Attachments") for a reference or try RegExra free online tool to help you build your own regular expressions.

Regular Expression Examples

Regex Explanation Successful input
 taken Used to validate whether the response contains the string "taken". Undertaken
 ^taken Used to validate whether the response starts with the string "taken".  taken over
 ^taken$ Used to validate whether the response matches the string "taken" exactly. This is equivalent to using the Equals constraint.  taken
 ^[0-9]{4}$ Used to validate whether the response is a 4-digit number (exactly 4 digits).  0063 
 ^[0-9]{4,10}$ Used to validate whether the response is a 4 to 10 digit number.  1234567890
 ^[vVbB][0-9]{6}$ Used to validate whether the response begins with either the letter V or B followed by a 6 digit number.  B123456 
 ^[0-9]{2}-[0-9]{6,7}\s[a-zA-Z]\s[0-9]{2}$ Used to validate whether the response is a Zimbabwean ID number (starts with two digits a dash and then six or seven digits; after the 6/7 string of digits there is always a space, then a letter then a space and finally two more digits; not case sensitive). 07-1234567 G 01 
 ^(\+?27|0)[6-9][1-7][0-9]{7}$ Used to validate whether the response is a South African mobile number (including the leading international dialing code). Alternatively, you could use a validation operator.  0828091234 

Validation Operators

Instead of writing your own regular expressions (or when a pattern is too complex to be validated using a regular expression), you can utilise the following pre-configured validation operators:

  • VALID_GS1_ID - validates the response according to the GS1 System of identification which allows you to validate barcodes and IDs which make use of a GS1 check digit.
  • VALID_RSA_ID - validates the response according to the South African National ID number standard.
  • VALID_RSA_MOBILE - validates that the response is a South African mobile number.
  • VALID_ZWE_MOBILE - validates that the response is a Zimbabwean mobile number.

Limitation

Numeric inputs of 10 digits or more cannot be entered; please use a text or phone number question type in these cases.


Availability

Regular Expressions are available from version 4.9.0 of the mobile application onward. Validation operators are available as per the table below:

Validation operator J2ME / Feature phones Android BlackBerry Windows Mobile
 VALID_GS1_ID 4.5.0 and above 4.5.0 and above  4.5.0 and above  1.0 and above 
 VALID_RSA_ID 4.5.0 and above
4.5.0 and above  4.5.0 and above  1.0 and above 
 VALID_RSA_MOBILE  4.7.0 and above  4.7.0 and above  4.7.0 and above  1.0 and above 
 VALID_ZWE_MOBILE  4.7.1 and above  4.7.1 and above 4.7.1 and above  1.0 and above 

Attachments
regex - cheat sheet.png 0.3 Mb Download File
Rss Comments
  • There are no comments for this article.