> For the complete documentation index, see [llms.txt](https://docs.collibra.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.collibra.com/ai-command-center/ai-business-users-governing-ai-use-cases/ai-command-center-assessments/working-with-assessment-templates/template-fields-and-settings/template-field-validation.md). Agents can also search and read this documentation through its [MCP server](https://docs.collibra.com/~gitbook/mcp).

# Validating user input in assessments

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](https://172513724-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRUJ2Awbxzd1UAaQbb7Dc%2Fuploads%2Fgit-blob-06b41c53495a066e6b3ce8e141a91022d690b7da%2Fassess-assessment-field-validation.png?alt=media)

## 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. The applicable fields are:
  * Asset Picker
  * Checkbox
  * Date Picker
  * Multi-Line Text Box
  * Number
  * Radio Button
  * Single-Line Text Box
  * User Picker
  * Yes/No
* **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](https://docs.collibra.com/ai-command-center/ai-business-users-governing-ai-use-cases/ai-command-center-assessments/working-with-assessment-templates/template-fields-and-settings/template-expression.md). 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.

| Field                   | Scenario                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | Expression                                                    | Error message                                                               |
| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- | --------------------------------------------------------------------------- |
| Review Date             | <p>You want to ensure that users enter only a future date in the <strong>Review Date</strong> field.</p><p>Suppose that the ID of the <strong>Review Date</strong> field is <strong>question1</strong>.</p>                                                                                                                                                                                                                                                                                                      | `{question1} > today()`                                       | Select a future date.                                                       |
| Retention Justification | <p>You want to ensure that if users enter a value greater than 3 in the <strong>Retention Period</strong> field, they must provide a justification in the <strong>Retention Justification</strong> field.</p><p>Suppose that the IDs of the <strong>Retention Period</strong> and <strong>Retention Justification</strong> fields are <strong>RetentionPeriod</strong> and <strong>RetentionJustification</strong>, respectively.</p>                                                                            | `{RetentionPeriod} <= 3 or {RetentionJustification} notempty` | Please provide a justification for a retention period longer than 3 months. |
| Data Steward            | <p>You want to ensure that if users select the value <strong>Confidential</strong> in the <strong>Data Classification</strong> field, they can't leave the <strong>Data Steward</strong> field empty.</p><p>Suppose that the IDs of the <strong>Data Classification</strong> and <strong>Data Steward</strong> fields are <strong>DataClassification</strong> and <strong>DataSteward</strong>, respectively. Suppose that the value of the <strong>Confidential</strong> option is <strong>Item 1</strong>.</p> | `{DataClassification} != "Item 1" or {DataSteward} notempty`  | Select 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.

| Field                  | Scenario                                                                                                                                                                                       | Rule                                                                                                      | Error 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.                                                  | <p><code>^PRJ-\d{4}$</code></p><p><em>Tip: Clear the <strong>Case insensitive</strong> checkbox.</em></p> | 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.

| Field         | Scenario                                                                            | Error message                |
| ------------- | ----------------------------------------------------------------------------------- | ---------------------------- |
| Contact Email | You 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.

| Field         | Scenario                                                                                               | Minimum value | Maximum value | Error message                      |
| ------------- | ------------------------------------------------------------------------------------------------------ | ------------- | ------------- | ---------------------------------- |
| Budget Amount | You want to ensure that users enter an amount between 1,000 and 10,000 in the **Budget Amount** field. | 1000          | 10000         | Enter 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.

| Field       | Scenario                                                                                                                 | Minimum length (in characters) | Maximum length (in characters) | Error message                                |
| ----------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------ | ------------------------------ | -------------------------------------------- |
| Description | You want to ensure that users enter a description containing between 20 and 200 characters in the **Description** field. | 20                             | 200                            | Enter 20–200 characters for the description. |
