Validating Form Data

Last Updated: 12/03/2015 Introduced in Verision: 2.0

One of the most common requirements of an application is to validate form inputs before accepting them. By assigning rules to forms within a flow, the system can validate form data before submission, preventing users from entering invalid information in an application. When the rule returns False, the validation will be enforced.

For example, data entered in an email address field should be in the proper format. A validation rule assigned to the email address field can check the format. If the format is invalid, an error displays when the user attempts to submit the form, and the error must be corrected before the form can be submitted.

Set validation rules for a form in the Form Designer, in the Properties panel, in the Custom Validation Rules section.

Example

Our example flow will illustrate how form data can be validated according to custom rules.

emailIsInvalid

 

In our example, we will set the Email ID 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. Our example assumes that our form Custom Validation Form  has already been created, and is ready to be configured. It also assumes that the rules that will validate the fields have also been created.

Many commonly used validation rules can be found in Root > System > Shared Designer Elements > System Defaults > Default Form Validation Rules.

To begin, navigate to a project folder and click the Create Flow button. To add a project folder, select the Actions button, then select Add > Designer Project and fill in the name and select OK.

createFlow

 

Name the flow and click OK. The form will open. From the Flow Designer’s startup window, expand the Flows, Rules, Forms and Reports > Forms [Interaction] > [Current Folder] category, select the Custom Validation Form component and click Add to add it to the workspace.

 

 flowStarts

Connect the form component to the End Step

To assign validation rules to the form, select it and click the Edit Form link at the top of the Properties panel.

editForm

 

To assign rules to a form, expand the Explorer panel and select Surface

selectSurface

 

In the Properties panel, locate the Rules field under the Custom Validation Rules section. Click Add to choose a custom rule to add to the form.

addCustRule

 

To create the rule, enter a name in the RuleName field. In the Rule drop-down list, navigate to the folder containing the rule and select it. The rule must return False in order for validation to be applied.

Many commonly used validation rules can be found in Root > System > Shared Designer Elements > System Defaults > Default Form Validation Rules.

pickRule

 

In the ValidationBreakText box, enter the message that will be displayed if the rule is broken. In the ApplyToControls list, select the checkbox next to each form control that the rule should be applied to.
In the Inputs box, select the input and click Edit.

editInputs

 

In the Edit object pop-up, you can further specify information about the input that the validation rule will check.

To specify that the input will come from a form, from the InputType drop-down list select Form.

To indicate the field on the form that the validation rule should check, select it from the  FormDataName drop-down list.

inputsEdited

 

Click Save to save the changes and close this pop-up, then click Save on the Edit object pop-up to save the validation rule. 

You can follow this process to add two more validation rules.

Add a validation rule to check that the Start Date is the current date or a date in the future . . .

editStartDateRule

 

. . . and should be run against data entered in the Start Date field on the form.

startDateEdited

 

Finally, you can add a validation rule to check that the End Date follows the Start Date . . .

addDateAfterTodayRule

 

. . . and should be run against data entered in the End Date field on the form.

editEndDateRule

 

If you have completed configuring the form, save the form and close the Form Designer.

The flow is also finished, save the flow and close the Flow Designer.

To see the flow in action, click the Action link in the new flow’s thumbnail and select Run > Run Flow.

runFlow

 

Enter an email address in an invalid format and click OK. An exclamation mark displays next to the field and the OK button, and a message appears with the text we entered in the ValidationBreakText box.

emailIsInvalid

 

When you enter invalid dates and click OK, the validation rules check the data, and the error message displays.

datesInvalid

 

Additional Resources