Validating user input in assessments

Important  This feature is available only in the latest UI.

You can ensure that the input that users provide in specific fields when conducting assessments meets specific criteria by using the Validation setting in assessment templates. The Validation setting allows you to enforce rules that control the type, format, or range of acceptable input for a field. For example, you can require users to enter a product code in a specific format, number within a specific range, or text of a specific length.

By using different validation types, such as logical expressions, regular expressions, email format, numeric ranges, and text length, you can guide users to provide correct and consistent input when taking assessments and show specific error messages when their input doesn’t comply. These error messages appear only when users try to complete or submit an assessment.

Image of an assessment with error messages

Key considerations for user input validation

  • Before you publish a template containing validation rules, consider using the Test Template tab to check how the validated fields behave and how the error messages you define appear.
  • Validation rules apply only when an input is provided in a field. If the field is left empty, no error message appears. If you want to ensure that users always fill a field, use the Required setting. The Required setting forces users to provide input, regardless of validation rules.
  • Some validation rules, such as those based on a logical expression, may depend on other fields. In such cases, an error message may appear even if the field being validated is empty, depending on the conditions defined in the expression.

Types of user input validation

The following types of validation are available for user input, depending on the field type:

  • Logical rule validation: Available for most fields.
  • Regular expression validation: Available only for Single-Line Text Box and Multi-Line Text Box fields.
  • Email validation: Available only for Single-Line Text Box fields.
  • Numeric validation: Available only for Number fields.
  • Text length validation: Available only for Single-Line Text Box and Multi-Line Text Box fields.

Logical rule validation

Logical rule validation ensures that input meets specific conditions defined by a Boolean expression. If the input meets the condition, no error message appears. If the input doesn't meet the condition, an error message appears.

The following settings are shown for logical rule validation in the template sidebar:

  • Expression: Enter the Boolean expression that evaluates to true or false. The expression can reference other fields in the template.
  • Error message: Enter the message that appears when the input doesn't meet the condition.
Example The following table contains examples of logical rule validation expressions for some fields. Each example includes the name of the field being validated, the scenario it addresses, the expression, and the corresponding error message.
FieldScenarioExpressionError message
Review Date

You want to ensure that users enter only a future date in the Review Date field.

Suppose that the ID of the Review Date field is question1.

{question1} > today()Select a future date.
Retention Justification

You want to ensure that if users enter a value greater than 3 in the Retention Period field, they must provide a justification in the Retention Justification field.

Suppose that the IDs of the Retention Period and Retention Justification fields are RetentionPeriod and RetentionJustification, respectively.

{RetentionPeriod} <= 3 or {RetentionJustification} notemptyPlease provide a justification for a retention period longer than 3 months.
Data Steward

You want to ensure that if users select the value Confidential in the Data Classification field, they can't leave the Data Steward field empty.

Suppose that the IDs of the Data Classification and Data Steward fields are DataClassification and DataSteward, respectively. Suppose that the value of the Confidential option is Item 1.

{DataClassification} != "Item 1" or {DataSteward} notemptySelect a data steward since the data classification is Confidential.

Regular expression validation

Logical rules validate input by checking Boolean expressions (true or false), while regular expressions validate input by checking text patterns. Regular expression validation ensures that input matches a specific text pattern. If the input matches the pattern, no error message appears. If the input doesn't match the pattern, an error message appears.

The following settings are shown for regular expression validation in the template sidebar:

  • Rule: Enter the text pattern that the input must match.
  • Case insensitive: Select this checkbox to make the validation ignore letter case.
  • Error message: Enter the message that appears when the input doesn't match the pattern.
Example The following table contains examples of regular expression validation rules for some Single-Line Text Box and Multi-Line Text Box fields. Each example includes the name of the field being validated, the scenario it addresses, the rule, and the corresponding error message.
FieldScenarioRuleError message
Column Naming Standard

You want to ensure that users enter a valid name in the Column Naming Standard field, following the format of lowercase letters and underscores only.

^[a-z_]+$Please use only lowercase letters and underscores for column names, for example, customer_id.
Data Asset ID

You want to ensure that users enter a valid ID in the Data Asset ID field, following the format DA-XXX-YYY, where XXX are uppercase letters and YYY are numeric digits.

^DA-[A-Z]{3}-\d{3}$Enter a data asset ID in the format DA-ABC-123.
Data Set Version

You want to ensure that users enter a valid version in the Data Set Version field, following the format vX.Y, where X and Y are numeric digits.

^v\d+\.\d+$Enter the data set version in the format v1.2.
Project Code

You want to ensure that users enter a valid code in the Project Code field, following the format PRJ-XXXX, where XXXX are numeric digits.

^PRJ-\d{4}$
Tip Clear the Case insensitive checkbox.

 

Enter the project code in the format PRJ-1234.
System Reference Code

You want to ensure that users enter a valid code in the System Reference Code field, following the format SYS-XXXX-YYYY, where XXXX are 2–4 uppercase letters and YYYY are numeric digits.

^SYS-[A-Z]{2,4}-\d{4}$Enter the system reference code in the format SYS-ABC-1234.

Email validation

Email validation ensures that input matches the format of an email address.

The following setting is shown for email validation in the template sidebar:

Error message: Enter the message that appears when the input isn't a valid email address.

Example The following table contains an example of email validation for a Single-Line Text Box field named Contact Email. The example includes the name of the field being validated, the scenario it addresses, and the corresponding error message.
FieldScenarioError message
Contact EmailYou want to ensure that users enter a valid email address in the Contact field. Enter a valid email address.

Numeric validation

Numeric validation ensures that input is a number within a specific range.

The following settings are shown for numeric validation in the template sidebar:

  • Minimum value: Enter the smallest number required for the input, without comma.
  • Maximum value: Enter the largest number allowed for the input, without comma.
  • Error message: Enter the message that appears when the input is outside the specified range.
Example The following table contains an example of numeric validation for a Number field named Budget Amount. The example includes the name of the field being validated, the scenario it addresses, the range, and the corresponding error message.
FieldScenarioMinimum valueMaximum valueError message
Budget AmountYou want to ensure that users enter an amount between 1,000 and 10,000 in the Budget Amount field.100010000Enter a number from 1000 to 10000.

Text length validation

Text length validation ensures that input meets specific character length requirements.

The following settings are shown for text length validation in the template sidebar:

  • Minimum length (in characters): Enter the minimum number of characters required for the input, without comma or period.
  • Maximum length (in characters): Enter the maximum number of characters allowed for the input, without comma or period.
  • Allow digits: Select this checkbox to allow numeric characters in the input.
  • Error message: Enter the message that appears when the input doesn't meet the specified length requirements.
Example  The following table contains an example of text length validation for a Multi-Line Text Box field named Description. The example includes the name of the field being validated, the scenario it addresses, the length requirements, and the corresponding error message.
FieldScenarioMinimum length (in characters)Maximum length (in characters)Error message
DescriptionYou want to ensure that users enter a description containing between 20 and 200 characters in the Description field.20200Enter 20–200 characters for the description.