HomeGuidesRecipesAPI
HomeGuidesAPILog In

Validator

A Validator question can validate the responses of other questions by comparing expected values to the given values.

Usage

You can define any number of "comparisons" with other questions, when these comparisons are met (eg: field length greater than a set maximum), then an error message will be displayed on the form.

These comparisons can take many forms and a very useful concept for this is 'Regular Expressions' or 'RegEx'.

Properties

MessageType in the Message you want to display.
QuestionA reference to another question/answer on the form to check
TypeOptions are: Compare Field Length Regular Expression
- Compare - The options for this property will change based on the "Type" selected. It gives you the options available for your comparison. A "Field Length" type only has Minimum field length and Maximum field length; whereas a "Compare" comparison has a number of options.
- Field Length - A "Field Length" type comparison checks the actual length of the entered value. For example, it could be used to check that a "Name" field is less than 50 characters long. Regular Expression - Use a "Regular Expression" type comparison to validate that the value of a reference question/answer matches an entered regular expression. For example, it could be used to check that a value is a valid email address.
ComparisonThe options for this are:
- Greater Than
- Greater Than or Equals
- Less Than
- Less Than or Equals
- Equals
- Not Equal To
- Begins With
- Ends With
- Contains
- Doesn't Contain
ExpressionType in the text that you want to validate against.
AddOnce all the settings are correct, use the Add button to add it to the validation box.
UpdateIf you make changes to existing settings you can select update to keep the changes.
RemoveIf you want to remove an existing validation, select it in the box and choose Remove.

Rule Groups

For more complex situations, multiple rules may need to be grouped together. From left to right of the rule controls; copy, paste, move selected up, move selected down, new 'all of', new 'any of', and switch selected group between 'all of' and 'any of'

An ‘all of’ group of rules is only satisfied if all of the rules in that group are met. If any one of them are not met, the answer is deemed irrelevant. Inversely, an ‘any of’ group needs only one of its rules to be met for the group of rules to be satisfied, making that answer relevant.

Decimal place validation

If you need your form project to capture numbers that must have a specific number of decimal places, you can add Regular Expression validation in Design. The following regular expressions will validate to the noted number of decimal places:

1 \d+(.\d{1,1})?
2 \d+(.\d{1,2})?
3 \d+(.\d{1,3})?
4 \d+(.\d{1,4})?
5 \d+(.\d{1,5})?
6 \d+(.\d{1,6})?