Validating Form Data with a Rule
  • 19 Jan 2022
  • 5 Minutes to read
  • Dark
    Light

Validating Form Data with a Rule

  • Dark
    Light

Article Summary

Overview

The following features are considered legacy content.

It is not recommended to introduce these features to new projects. Support for these features have been maintained just to grant time for projects to shift away from legacy content towards the new preferred method: Active Form Flows. 

Failure to do so may result in losing work involving legacy content in the future.

Validation Rules evaluate a value within a Form control and return a “True” or “False” outcome, depending on whether the form value satisfies the rule’s condition(s). If a Validation Rule returns “False”, the validation breaks, and a custom message is displayed on the Form control.

There are several form validation rules included with Decisions. They are found under System > Designers > Catalog > System Defaults > Default Form Validation Rules. Users can also create their own Validation Rules in Designer Folders.

It is highly recommended not to edit the default rules; please contact support@decisions.com if you have any questions.

To learn about Validating Form Data with a Flow, please navigate here.

Example

This example will illustrate how an Employee Leave Request form can be validated according to default rules. The Validation Rule will set the form component's Email Address field only to accept valid email addresses. Start Date will only accept today's date or a date in the future. End Date will only accept dates occurring after today.

  1. Navigate to a Designer Folder and select Create Flow
  2. Name the Flow and select CREATE.
  3. Select the Done outcome path of the Start step.
  4. In the Add After dialog, select the Show Form step in the Favorite Steps category. Select ADD.


  1. With the Show Form step selected, in the Properties panel, select PICK OR CREATE FORM.
  2. Select CREATE under Create New. Choose Form, name the Form, and then select CREATE.

  3. The Form has one Button (Submit), three Labels (Email Address, Start Date, End Date), one Text Box (Email Address Text Box), and finally two Date Time Pickers (Start Date Picker, End Date Picker).

  4. To assign Validation Rules to the Form, select the workspace and navigate to the Properties panel.
  5. In the Properties panel, under Form Rules > Legacy> Validation Rules, select ADD NEW.

  6. Name the rule "Check Email". 
  7. Leave the Validation Source as Rule
  8. Under the Rule text box, select Pick
  9. Navigate to System > Designers > Catalog > System Defaults > Default Form Validation Rules and choose Is Valid Email.

  10. Back in the Edit Validation Rules dialog, under Rule Inputs, select Update Inputs
  11. Within the Rule Inputs box, choose the input and select Edit [pencil shaped icon].

  12. In the Edit Rule Inputs dialog, specify that the input will come from a Form. 
  13. From the Input Type drop-down list, select the Form Component. To indicate which field on the form that the validation rule will check, select it from the  Form Data Name drop-down list, choose "Email Text Box".
  14. Select OK.


  15. Back in the Add Validation Rules dialog, under Rule Data > Validation Break Text Box, enter the message displayed if the rule is broken.
  16. In the Apply To Controls list, select the checkbox next to the form control that the rule will be applied to, "Email Text Box".
  17. Select OK to save the changes and close this dialog.

  18. Follow the above process to add two more validation rules.
  19. In the Properties panel, under Form Rules > Validation Rules, select Add New.
  20. Add a Validation Rule to check that the Start Date is the current date or a date in the future.
  21. Configure like the previous Validation Rule but instead choose Date After Today as the Rule
  22. Update the Inputs and configure to the correct Form Component, "Start Date Picker". Give the Validation a break text and choose which control to apply the rule to.

  23. To have this Validation Rule run at start-up in the Edit Validation Rules dialog, navigate to Rule Execution. 
  24. Select the checkbox next to Run Rule On Form Show
  25. Select OK to save and close.

  26. Add a validation rule to check that the End Date follows the Start Date.
  27. In the Properties panel, under Form Rules > Validation Rules, select Add New.
  28. Configure like the previous Validation Rule, choose Date After Today as the Rule. Update the Inputs and configure to the correct Form Component, "End Date Picker". Give the Validation a break text and choose which control to apply the rule to.
  29. To have this Rule run at start-up, navigate to Rule Execution, and select the checkbox next to Run Rule On Form Show
  30. Select OK to save and close.

Debug: Validating Text Box and Date Pickers

  1. Save and close the Form Designer. In the Flow Designer, be sure all outcome paths are connected. Select Debug in the top action panel.
  2. When the Form displays the Start Date Picker and End Date Picker automatically show the validation error. When invalid dates are entered, the validation rules check the dates, and the error message displays.
  3. Enter an email address in an invalid format, and the error message appears.
  4. When valid information is entered, the rules return true, and users can select Submit.


Validation Rule on a File Upload Control

  1. To apply a Validation Rule to a File Upload component, add a "Doctors Note (If Applicable)" label and a File Upload button to the Form.
  2. In the Forms Property panel under Validation Rules, select Add New. Name the rule "Check File Type". Leave the Validation Source as Rule
  3. Under the Rule text box, select CREATE. Name the Rule and select CREATE.

  4. Add FileData as the Input Data to the Rule.
  5. The Validation Rule will read: If File.FileName String Ends with Any in List [endsWith] .doc, .docx, .pdf [caseInsensitive] False. 
  6. Save and close the Rule Designer.

  7. Back in the Add Validation Rules dialog, under Rule Inputs, select Update Inputs. Within the Rule Inputs box, choose the input and select Edit [pencil shaped icon].

  8. In the Edit Rule Inputs dialog, specify that the input will come from a form; from the Input Type drop-down list, select Form Component
  9. To indicate which field on the form that the validation rule will check, select it from the  Form Data Name drop-down list, choose "Supporting Documents".
  10. Select OK.

  11. Back in the Add Validation Rules dialog, under Rule Data > Validation Break Text, enter the message displayed if the rule is broken.
  12. In the Apply To Controls list, select the checkbox next to the form control that the rule will be applied to, "File Upload".
  13. Select OK to save the changes and close this dialog.

Debug: Validating File Upload Control

  1. Save and close the Form Designer, select Debug in the top action panel.
  2. Test the File Upload component to see if the Validation Rule is working properly.



Was this article helpful?