Validating Form Data with a Rule
  • 27 May 2021
  • 4 Minutes to read
  • Dark
    Light
  This documentation version is deprecated, please click here for the latest version.

Validating Form Data with a Rule

  • Dark
    Light

Article summary

Overview

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 the platform that can be found under System > Designers > Catalog > System Defaults > Default Form Validation Rules. Users can also create their own Validation Rules in Designer Folders.

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

To learn more about Validating Form Data with a Flow, please navigate to the Validating Form Data with a Flow article.


Example

This example will illustrate how an Employee Leave Request Form can be validated according to default Rules. The Validation Rule will set the Email Address field of the Form component to only 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. To begin, navigate to a Designer Folder and select CREATE FLOW from the bottom action panel.
  2. In the resulting Create Flow window, select and name the Default Flow [Leave Request] and select CREATE.2019-09-12_153526.png
  3. In the Flow Designer, add a Show Form step from the Favorite Steps category.

    2019-09-12_153727.png

  4. Name the Form "Leave Request" then select CREATE.

    2019-09-12_153753.png

  5. Configure the Form with 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).

    2019-09-12_154338.png

  6. To assign Validation Rules to the Form, select the workspace and navigate to the Properties panel > Form Rules > Validation Rules selector and click Add New.2019-09-12_154542.png
  7. Name the Rule "Check Email".
  8. Leave the Validation Source as Rule
  9. Under the Rule text box select Pick
  10. Navigate to System > Designers > Catalog > System Defaults > Default Form Validation Rules and choose Is Valid Email.

    2019-09-12_154907.png

  11. In the Add Validation Rules dialog, under Rule Inputs select Update Inputs
  12. Within the Rule Inputs box, choose the input and select Edit [pencil shaped icon].

    2019-09-12_155107.png

  13. 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
  14. 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". Click OK.2019-09-12_155246.png
  15. In the Add Validation Rules dialog, under Rule Data > Validation Break Text Box, enter the message that will be displayed if the Rule is broken.
  16. In the Apply To Controls list, select the boolean next to the Form Control that the Rule will be applied to, "Email Text Box". Click OK.

    2019-09-12_155336.png

  17. In the Properties panel, under Form Rules > Validation Rules select Add New.
  18. Repeat the previous steps to add two more Validation Rules. 

    2019-09-12_155548.png

  19. Add a Validation Rule to check that the Start Date is the current date or a date in the future.
  20. Configure like the previous Validation Rule but instead choose Date After Today as the Rule
  21. Update the Inputs and configure to the correct Form Component, "Start Date Picker". 
  22. Give the Validation a break text and choose which control to apply the Rule to.

    2019-09-12_160255.png

  23. To have this Validation Rule run at start-up in the Edit Validation Rules dialog navigate to Rule Execution, select the checkbox next to Run Rule On Form Show. Click OK.

    2019-09-12_160329.png

  24. Finally, add a Validation Rule to check that the End Date follows the Start Date.
  25. In the Properties panel, under Form Rules > Validation Rules select Add New.

    2019-09-12_160348.png

  26. Configure like the previous Validation Rule, choose Date After Today as the Rule.
  27. Update the Inputs and configure to the correct Form Component, "End Date Picker". 
  28. Give the Validation a break text and choose which control to apply the Rule to.2019-09-12_160708.png
  29. To have this Rule run at start-up also, navigate to Rule Execution, select the checkbox next to Run Rule On Form Show. Click OK.

    2019-09-12_160329.png

  30. Save and close the Form Designer.
  31. Connect the Form outcome to the End step in the Flow Designer.
  32. Select Debug from the top action panel.

    2019-09-12_160957.png

  33. When the Form displays the Start Date Picker and End Date Picker will automatically show the Validation error. 
  34. Enter an email address in an invalid format to test the Rule. When valid information is entered the Rules return true and users are able to select Submit.

    Video_2019-09-12_162312.gif

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 component to the Form.
  2. In the Form's Properties panel > Validation Rules, select Add New.
  3. Name the Rule "Check File Type". 
  4. Leave the Validation Source as Rule
  5. Under the Rule text box select CREATE. Name the Rule and select CREATE.2019-10-03_144409.png
  6. Add FileData as the Input Data to the Rule.
  7. The Validation Rule will read: If File.FileName String Ends with Any in List [endsWith] .doc, .docx, .pdf [caseInsensitive] False. 
  8. Save and close the Rule Designer.

    2019-10-03_144517.png

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

    2019-10-03_145402.png

  11. 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
  12. 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". Click OK.

    2019-10-03_144549.png

  13. In the Add Validation Rules dialog, under Rule Data > Validation Break Text, enter the message that will be displayed if the Rule is broken.
  14. In the Apply To Controls list, select the boolean next to the Form Control that the Rule will be applied to, "File Upload". Click OK. 2019-10-03_144712.png
  15. Save and close the Form Designer.

Debug

  1. Select Debug from the top action panel.
  2. Test the File Upload component to see if the Validation Rule is working properly.Video_2019-10-03_145729.gif

Was this article helpful?