Validation Rules for Screen Controls

Use these rules to describe how to validate your Screen controls.

Overview

Use validation rules in a control to constitute what is a valid value entered for that control.

If a control that has a Validation Rules setting but does not contain any value or properly structured validation rule, that control automatically passes validation.

If a control is hidden using Visibility Rules, any Validation Rules associated with that control are not evaluated upon submission of the Screen.

Controls That Provide Validation

The following Screen Builder controls use the validation rules:

Create a Validation Rule

Follow these steps to add a validation rule to a Screen Builder control that provides validation:

  1. Access the Variable panel for the control while in Design mode, and then locate the Validation Rules setting.

  2. Select the rule that this control validates against.

  3. Click Save. Parameters for the selected rule display. Parameter settings display which ones are required to properly configure the rule.

  4. Enter the parameter settings that this control uses to validate against. See Validation Rule Settings, and then locate the validation rule for its parameters.

Ensure Validation Fails for an Undefined Setting

If you want a validation to fail for undefined or '', use the required rule.

Validation Rule Settings

Accepted

Use the Accepted validation rule to validate acknowledgement of this control. This is useful to validate "Terms of Service" acceptance.

Follow these steps to configure the parameter(s) for an Accepted validation rule:

  1. From the Select drop-down menu in the Validation Rules setting, select Accepted. The Accepted validation rule has no parameters.

After Date

Use the After Date validation rule to validate that the value entered into this control must be after (later than) a specified date. If the entered value is in datetime format, then the time format is ignored.

The value entered into this control must be in one of the following formats:

  • Date format: YYYY-MM-DD. Example: "2020-07-01"

  • Datetime format: YYYY-MM-DD HH:MM:SS. Example: "2020-07-01 14:25:15"

Follow these steps to configure the parameter(s) for an After Date validation rule:

  1. In the Date setting, enter the date in date format that this control's value must be after (later than). This is a required setting.

After Or Equal To Date

Use the After or Equal to Date validation rule to validate that the value entered into this control must be the same or after (later than) a specified date. If the entered value is in datetime format, then the time format is ignored.

The value entered into this control must be in one of the following formats:

  • Date format: YYYY-MM-DD. Example: "2020-07-01"

  • Datetime format: YYYY-MM-DD HH:MM:SS. Example: "2020-07-01 14:25:15"

Follow these steps to configure the parameter(s) for an After or Equal to Date validation rule:

  1. In the Date setting, enter the date in date format that this control's value must be the same or after (later than). This is a required setting.

Alpha

Use the Alpha validation rule to validate that the value entered into this control must be contain only alphabetic characters.

Follow these steps to configure the parameter(s) for an Alpha validation rule:

  1. From the Select drop-down menu in the Validation Rules setting, select Alpha. The Alpha validation rule has no parameters.

Alpha-Numeric

Use the Alpha-Numeric validation rule to validate that the value entered into this control must contain only alphanumeric characters.

Follow these steps to configure the parameter(s) for an Alpha-Numeric validation rule:

  1. From the Select drop-down menu in the Validation Rules setting, select Alpha-Numeric. The Alpha-Numeric validation rule has no parameters.

Before Date

Use the Before Date validation rule to validate that the value entered into this control must be before (earlier than) a specified date. If the entered value is in datetime format, then the time format is ignored.

The value entered into this control must be in one of the following formats:

  • Date format: YYYY-MM-DD. Example: "2020-07-01"

  • Datetime format: YYYY-MM-DD HH:MM:SS. Example: "2020-07-01 14:25:15"

Follow these steps to configure the parameter(s) for a Before Date validation rule:

  1. In the Date setting, enter the date in date format that this control's value must be before (earlier than). This is a required setting.

Before Or Equal To Date

Use the Before or Equal to Date validation rule to validate that the value entered into this control must be the same or before (earlier than) a specified date. If the entered value is in datetime format, then the time format is ignored.

The value entered into this control must be in one of the following formats:

  • Date format: YYYY-MM-DD. Example: "2020-07-01"

  • Datetime format: YYYY-MM-DD HH:MM:SS. Example: "2020-07-01 14:25:15"

Follow these steps to configure the parameter(s) for a Before or Equal to Date validation rule:

  1. In the Date setting, enter the date in date format that this control's value must be the same or before (earlier than). This is a required setting.

Between Min & Max

Use the Between Min & Max validation rule to validate that the numerical value that this control contains is between the specified minimum value and a maximum value.

The Between Min & Max validation rule evaluates the following:

  • integers

  • file sizes

The Between Min & Max validation rule does not evaluate the number of characters in a text, but only the value of an entered number. Use one or both of the following to validate the number of characters in a text:

Furthermore, the Between Min & Max validation rule does not evaluate calendar dates, such as when an entered value in that control is between two dates. Use any of the following to validate date-related values:

Follow these steps to configure the parameter(s) for a Between Min & Max validation rule:

  1. In the Min parameter setting, enter the numeric value that this control's value must be equal to or no lower than. This is a required setting.

  2. In the Max parameter setting, enter the numeric value that this control's value must be equal to or no greater than. This is a required setting.

Date

Use the Date validation rule to validate that the value entered into this control is in date or datetime format.

One of the following formats validates that the entered value is a date:

  • Date format: YYYY-MM-DD. Example: "2020-07-01"

  • Datetime format: YYYY-MM-DD HH:MM:SS. Example: "2020-07-01 14:25:15"

Follow these steps to configure the parameter(s) for an Date validation rule:

  1. From the Select drop-down menu in the Validation Rules setting, select Date. The Date validation rule has no parameters.

Email

Use the Email validation rule to validate that the value entered into this control is formatted as an email address.

Follow these steps to configure the parameter(s) for an Email validation rule:

  1. From the Select drop-down menu in the Validation Rules setting, select Email. The EMail validation rule has no parameters.

In

Use the In validation rule to validate that the value entered into this control exactly matches the given parameter setting. The validation rule evaluates the entire value entered in the control and considers case-sensitivity and empty spaces. The control's scope of evaluation may be within an array or a string. See In Validation Rule Examples.

Follow these steps to configure the parameter(s) for an In validation rule:

  1. In the Values parameter setting, enter the value to evaluate if it exactly matches the control's selected or entered value. This is a required setting.

Format a list in the Values parameter setting by separating the values with commas only, no spaces:

value1,value2,value3

In Validation Rule Examples

The following JSON Request data represents the JSON array for a Select List control under evaluation.

doctors = [
    {id: 1, name: 'Adam Ardin', gender: 'male'},
    {id: 2, name: 'Amanda Creek', gender: 'female'},
    {id: 3, name: 'Lucy Morales', gender: 'female'},
    {id: 4, name: 'Mindy Smith', gender: 'female'},
    {id: 5, name: 'Toby Tomlinson', gender: 'male'}
]

The Select List control contains the following settings:

  • This control is configured to return the value of the property name. Therefore, the doctors' names display as options in the Select List control.

  • This control has an In validation rule to evaluate if Mindy Smith is included in that control's selection.

If the Request participant selects the Mindy Smith option from that Select List control, then that control passes validation.

Max Length

Use the Max Length validation rule to validate that the value entered into this control is no greater than a specified length.

The Max Length validation rule evaluates the following:

  • a maximum number of characters in a string

  • a maximum integer value

  • a maximum file size

The Max Length validation rule does not evaluate calendar dates, such as when an entered value in that control is no later than a particular date.

Follow these steps to configure the parameter(s) for a Max Length validation rule:

  1. In the Max Input parameter setting, enter the numeric value that this control's value must be equal to or no greater than. This is a required setting.

Min Length

Use the Min Length validation rule to validate that the value entered into this control is no less than a specified length.

The Min Length validation rule evaluates the following:

  • a minimum number of characters in a string

  • a minimum integer value

  • a maximum file size

The Min Length validation rule does not evaluate calendar dates, such as when an entered value in that control is no earlier than a particular date.

Follow these steps to configure the parameter(s) for a Min Length validation rule:

  1. In the Min Input parameter setting, enter the numeric value that this control's value must be equal to or no less than. This is a required setting.

Not In

Use the Not In validation rule to validate that the value entered into this control does not match the given parameter setting. The validation rule evaluates the entire value entered in the control and considers case-sensitivity and empty spaces. The control's scope of evaluation may be within an array or a string. See Not In Validation Rule Examples.

Follow these steps to configure the parameter(s) for a Not In validation rule:

  1. In the Values parameter setting, enter the value to evaluate if it is not within the control's selected or entered value. This is a required setting.

Format a list in the Values parameter setting by separating the values with commas only, no spaces:

value1,value2,value3

Not In Validation Rule Examples

The following JSON Request data represents the JSON array for a Select List control under evaluation.

doctors = [
    {id: 1, name: 'Adam Ardin', gender: 'male'},
    {id: 2, name: 'Amanda Creek', gender: 'female'},
    {id: 3, name: 'Lucy Morales', gender: 'female'},
    {id: 4, name: 'Mindy Smith', gender: 'female'},
    {id: 5, name: 'Toby Tomlinson', gender: 'male'}
]

The Select List control contains the following settings:

  • This control is configured to return the value of the property name. Therefore, the doctors' names display as options in the Select List control.

  • This control is configured to allow multiple selections.

  • This control has a Not In validation rule to evaluate if Mindy Smith is not included in that control's selection.

If the Request participant selects multiple options from that Select List control, but the Mindy Smith option is not among them, then that control passes validation.

Regex

Use the Regex validation rule to validate that this control's value contains content as determined by a specified regular expression. A regular expression, abbreviated as regex, is a sequence of letters and symbols that defines a logical search pattern from which to search this control's content to validate that strings meet the defined pattern. This validation rule is useful to parse the contents of a control's value even if that control's Request variable contains programming code such as HTML or JSON.

Need a primer on regular expression syntax? See this primer, and then use RegExr to learn, build, and test your regular expressions.

Follow these steps to configure the parameter(s) for a Regex validation rule:

  1. In the Regex Pattern setting, enter the regular expression from which to validate this control's value contains that content. This is a required setting.

Required

Use the Required validation rule to validate that this control has a value and is not empty.

A control constitutes as having no value in the following circumstances:

  • The value is null.

  • The value is an empty string that contains no characters.

  • The value is an empty JSON array or empty JSON object.

  • The value is an uploaded file with no path.

Follow these steps to configure the parameter(s) for a Required validation rule:

  1. From the Select drop-down menu in the Validation Rules setting, select Required. The Required validation rule has no parameters.

Required If

Use the Required If validation rule to validate that this control has a value and is not empty if another control in that Screen page contains a specific value. If the control being monitored contains a specific value, then the control under evaluation is required. See Required If Validation Rule Examples.

The Required If validation rule is the inverse of the Required Unless rule.

A control constitutes as having no value in the following circumstances:

  • The value is null.

  • The value is an empty string that contains no characters.

  • The value is an empty JSON array or empty JSON object.

  • The value is an uploaded file with no path.

Follow these steps to configure the parameter(s) for a Required If validation rule:

  1. In the Variable Name parameter setting, enter the Variable Name setting value to monitor for its value. This is a required setting.

  2. In the Variable Value parameter setting, enter the value that must be entered into that control to make this control required. This is a required setting.

Required If Validation Rule Examples

A Request participant enters information into a Task for a job application. If that Task assignee selects from a Select List control in which country that person lives. If the Task assignee selects the option United States (US), then another Select List control becomes required to select from which US state that person lives.

This example demonstrates depending controls: one control depends on another to be required. This example also demonstrates how a control depends on the specific value of another.

See the following .json files below for this example:

  • List of countries in JSON format: Countries for Select List Control "Required If" Validation Example

  • List of US states and territories in JSON format: US States for Select List Control "Required If" Validation Example

Follow these steps to implement this example:

  1. Add a Select List control to your Screen, and then configure its settings. Make note of its Variable Name setting value you set for that control. This control displays the list of countries as its options.

  2. Provide the options for this Select List control. In doing so, edit options as JSON:

    1. Download the file below Countries for Select List Control "Required If" Validation Example.

    2. Review the JSON data. Notice that each JSON object contains the following:

      • content: A property called content represents the label for each option (in this example, a country name). The label for each Select List option may contain any string as long as it is in the content property of each JSON object.

      • value: A property called value that contains a numeric value that corresponds with each label option. The value property may contain any string as long as it is in the value property of each JSON object. Notice that the JSON object that contains the content property value of United States has a value property of 232. In this example, if the option corresponding with the 232 value is selected, then the second Select List control is required.

    3. Copy this file's JSON data.

    4. Paste it into the JSON Data setting.

  3. Add a second Select List control to the same Screen page, and then configure its settings. This control displays the list of US states and territories as its options, and represents the required control if a specific setting in the first Select List control contains a specific value.

  4. Provide the options for this Select List control. In doing so, edit options as JSON:

    1. Download the file below US States for Select List Control "Required If" Validation Example.

    2. Copy this file's JSON data.

    3. Paste it into the JSON Data setting.

  5. Add a Required If validation rule to the second Select List control that displays the list of US states and territories.

  6. In the Variable Name setting of the Required If validation rule, enter the Variable Name setting value for the first Select List control that displays the list of countries as its options.

  7. In the Variable Value setting of the Required If validation rule, enter 232, which is the value property value that corresponds with the content property value United States.

  8. Add a Submit Button control to the same Screen page, and then configure its settings.

Required Unless

Use the Required Unless validation rule to validate that this control has a value and is not empty unless another control in that Screen page contains a specific value. If the control being monitored for its value has a specific value, then the control under evaluation is not required. See Required Unless Validation Rule Examples.

The Required Unless validation rule is the inverse of the Required If rule.

A control constitutes as having no value in the following circumstances:

  • The value is null.

  • The value is an empty string that contains no characters.

  • The value is an empty JSON array or empty JSON object.

  • The value is an uploaded file with no path.

Follow these steps to configure the parameter(s) for a Required Unless validation rule:

  1. In the Variable Name parameter setting, enter the Variable Name setting value to monitor for its value. This is a required setting.

  2. In the Variable Value parameter setting, enter the value that must be entered into that control to exempt this control from being required. This is a required setting.

Required Unless Validation Rule Examples

A Request participant enters information for a Task regarding United States (US) federal taxes. If that Task assignee selects from a Select List control that person lives in California, then that person is exempt from a federal tax credit. If the Task assignee selects the option California, then a Line Input control becomes required to enter tax information. If any other option is selected, then the Line Input control is not required.

This example demonstrates depending controls: one control depends on another to be required. This example also demonstrates how a control depends on the specific value of another.

See the following .json file below for this example: US States for Select List Control "Required Unless" Validation Example.

Follow these steps to implement this example:

  1. Add a Select List control to your Screen, and then configure its settings. Make note of its Variable Name setting value you set for that control. This control displays the list of US states and territories as its options.

  2. Provide the options for this Select List control. In doing so, edit options as JSON:

    1. Download the file below US States for Select List Control "Required Unless" Validation Example.

    2. Review the JSON data. Notice that each JSON object contains the following:

      • content: A property called content represents the label for each option (in this example, a US state or territory). The label for each Select List option may contain any string as long as it is in the content property of each JSON object.

      • value: A property called value that contains a numeric value that corresponds with each label option. The value property may contain any string as long as it is in the value property of each JSON object. Notice that the JSON object that contains the content property value of California has a value property of 6. In this example, if the option corresponding with the 6 value is selected, then the Line Input control is not required.

    3. Copy this file's JSON data.

    4. Paste it into the JSON Data setting.

  3. Add a Line Input control to the same Screen page, and then configure its settings. The Request participant enters into this control required information unless a specific setting in the Select List control contains a specific value.

  4. Add a Required Unless validation rule to the Line Input control control.

  5. In the Variable Name setting of the Required Unless validation rule, enter the Variable Name setting value for the Select List control that displays the list of US states and territories as its options.

  6. In the Variable Value setting of the Required Unless validation rule, enter 6, which is the value property value that corresponds with the content property value California.

  7. Add a Submit Button control to the same Screen page, and then configure its settings.

Same

Use the Same validation rule to validate that the value entered into this control matches the value of a specified control.

Follow these steps to configure the parameter(s) for a Same validation rule:

  1. In the Variable Name parameter setting, enter the Variable Name setting value to evaluate if the control under evaluation matches its value. This is a required setting.

URL

Use the URL validation rule to validate that the value entered into this control is formatted as a Uniform Resource Locator (URL).

Follow these steps to configure the parameter(s) for a URL validation rule:

  1. From the Select drop-down menu in the Validation Rules setting, select URL. The URL validation rule has no parameters.

Last updated

© Copyright 2000-2024 ProcessMaker Inc. All rights reserved.