Creating a Form Validation Rule

Last Updated: 05/03/2018 Introduced in Version: 2.0
This tutorial demonstrates how to use Validation Rules on Forms in Decisions. Validation Rules evaluate a form value and return a “True” or “False” outcome, depending on whether the form value satisfies the rule’s condition(s). If Validation Rule returns “False”, validation brakes and custom message is displayed on the Form control. The platform includes several form validation rules, found under System > Designers > Catalog > System Defaults > Default Form Validation Rules. To keep all form validation rules together for organizational purposes, you could create additional validation rules here (however, this is not required).

Example

In this scenario, a minimum age for an applicant is at least 18 years old. A validation rule will evaluate date of birth of the applicant against the current date and enforce this business rule for minimum age. Our example validation rule will expect a date. If the date of birth plus 18 years is earlier than current date, the rule will return a truthful outcome. Otherwise, it will return false and show validation message.

We begin in the Designer Folder with clicking Create Rule > Create Rule on the Folder Actions Panel.

In the resulting window we Name the Rule “Applicant Over Age 18” and click Ok to proceed to the Rule Designer.

Our Rule needs “Date Of Birth” Date input to evaluate. In the Start Rule window we click Show Editor under Rule Input Data to define inputs.

Then, in Data Definitions window we Name our input and pick Date Time data type. Click Close to save and continue.

Rule Input Data is configured and we click Add New Rule Step to start building our Rule.

In the resulting window we pick our DOB data to evaluate and click Next.

To evaluate our date of birth value we are going to create a simple Flow instead of a verb. We expand Common > Evaluate category, pick Evaluate and click Next.

Then, we click Create under Flow picker.

We Name the Flow and click Ok to proceed to the Flow Designer.

In the Flow Designer we need to create a Date Of Birth as a Flow Input. We select Start Step and in the Step Editor window we locate Flow Input Data settings and click Show Editor. In the Data Definitions window we Name our data and pick Date Time type. Then, in the Mapping settings for our date we Select Value of DOB date. Click Close when finished.

Next, we add Add Years step from All Steps [Catalog] > Data > Dates category.

Add Years step takes in source Date (Date Time) and years (Int) inputs. For source Date we Select Value of our DOB flow input and for years we define Constant 18. The output from this step will be a calculated date that we need to compare with current date and check if it is less than current date.

On the outcome path from Add Years step we add Less Than (Date) step from All Steps [Catalog] > Data > Dates category.

Next, we are going to configure Inputs for Less Than (Date) step. For the end Date input we select Current Date Time Mapping Type.

For the first Date input, we Select Value of Add Years_Output.

Then, we locate and expand Outcomes settings on the Less Than (Date) step and uncheck Expose Step as a Rule check-box.

Next, we connect Done outcome from Less Than (Date) to the End Step in our Flow. Our Flow has to output Boolean Result (True or False). For the Result input on the End Step we Select Value of Less Than Date_Output.

This completes our evaluation Flow. We can save the Flow and close Flow Designer.

Back in the Rule Designer we click Done to save and close Rule Step Builder dialog.

Lastly, in order for us to be able to use this Rule as a Validation Rule on the Form, we need to change its Behavior. On the Rule Settings panel we locate Behavior Type in the Output section and pick Form Rule.

This completes our Rule Design. We can save the Rule and close Rule Designer.

The validation rule is established in the Form Designer, from the Surface level for the form. To learn how to apply the rule, see the topic “Applying a Form Validation Rule.”

Additional Resources