A control that takes user input can have validation rules added to them. What is a validation rule? It is a requirement the user must follow in order for the control to accept the input.
Currently, there are only two controls that can have field validation rules set: the TextInput control and the Dropdown control. The Validation Rules can be accessed for each control by selecting the down arrow (▾) on the control to open its contextual menu:
Doing so will open up the control's Validation Window. The below image is an example of the TextInput's validation controls. To add a rule to the control, you select it from the validation rule list on the right. Some rules require further configuration (e.g. the Minimum Field Length needs to know how many characters is required as minimum).
There are four validation rules a control may have (depending on the type of control):
- Field is required - Validate that a field has been populated.
- Field has a maximum length - Validate that a field contains a valid email address. Multiple addresses may be separated by a comma.
Note: QuickBooks allows for multiple email address in an email field and thus Method allows for multiple emails to be consistent. However, in all of our stock apps, only the first email is used and any emails after the comma are ignored.
- Field has a minimum length - Validate that a field does not exceed a certain number of characters.
- Field contains a valid email address - Validate that a field is at least a certain number of characters.
If a validation rule is added to a control, the action Validate Controls on Screen can be used to check if the object obeys these rules. The Save All action can also be configured to check validation rules before saving.
If the input for the control breaks a rule, this action will highlight the field in red, display what needs to be fixed, and all other actions below this action will be ignored.
Example: Below, the Name field is required and the action was called to validate this field. Since the field was empty, it was outlined in red and text is displayed to show what the validation error was. Any other action after this action is ignored.