Field Validation

What is field validation and how does Method implement it?

Updated over a week ago

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 Contains a Valid Email Address: 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 Maximum Length: Validate that a field does not exceed a certain number of characters.

  • Field Minimum Length: Validate that a field is at least a certain number of characters.

  • Field Contains No Malicious Values: Validates the field does not contain malicious text (Javascript or SQL injections). HTML text is still allowed.

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.

Did this answer your question?