--- title: "Configure validation rules" slug: "bc-configure-validation-rules" description: "Define and manage field-level validation rules in data policies to ensure data quality and compliance in your master data records." updated: 2026-06-25T09:59:00Z published: 2026-06-25T09:59:00Z canonical: "docs.staedean.com/bc-configure-validation-rules" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.staedean.com/llms.txt > Use this file to discover all available pages before exploring further. # Configure validation rules Validation rules define the quality checks applied to individual fields on a master data record. For each field you want to govern, you add the field to the policy's **Field** **Validation** section and then define one or more rules on it. Each rule specifies what the field value must satisfy, what happens when it does not, and optionally under what conditions the rule should run. **Purpose** Define field-level validation rules within a policy version so that users are guided or blocked, when they enter data that does not meet the defined standard. ### **Navigation** 1. Use the **Tell Me** search (**Alt+Q** or the magnifying glass icon in the top bar) and enter **Data Policies**. Select the result under **Administration**. 2. Opens the **Data Policies**. 3. Click the **Policy Table ID** (e.g. **18** for Customer) to open the **Data Policy** form. 4. The **Field Validation** tab is visible in the lower section of the form. ### **Steps** **Add a field to the Field Validation tab** 1. In the **Field Validation** tab, click **New Line**. A new row is added. 2. Click the lookup in the **Field No.** column. A list of fields from the policy's source table appears. 3. Select the field you want to validate (for example, **E-Mail** or **Credit Limit**). 4. The **Field Caption** column is automatically populated with the field's display name. 5. The **No. of Validation Rules** column shows 0. No rules are defined yet for this field. Repeat this step for each field you want to validate. > [!NOTE] > Note > > You can add multiple fields to the **Field Validation** tab. Each field is validated independently according to its own rules. **Add a validation rule** 1. Select the row of the field you want to configure. 2. Click **Validation Rules**. The **Data Validations** page opens, filtered to the selected field within this policy version. This is where individual rules are defined. 3. In the **Data Validations** page, click **+ New** in the action bar. 4. A new row is added. Fill in the following fields: | **Field** | **Description** | | --- | --- | | **Field No.** | Auto-populated from the policy line | | **Field Caption** | Auto-populates the display name | | **Validation Type** | Type of validations; - Data pattern - Range Expression - Mandatory, or - Blank | | **Pattern Name** | The validation pattern to use. This is enabled only when Validation Type is **Data Pattern** or **Range Expression** | | **Outcome** | The system response when the rule fails; **Default Error**, **Custom Error**, and **Custom Warning** | | **Validation Message** | The message shown to the user, required for **Custom Warning** and **Custom Error** outcomes | | **No. of Active Data Conditions** | Displays how many conditions are active for this rule (Read-only) | #### **Validation Type options** | **Validation Type** | **Behaviour** | | --- | --- | | **Mandatory** | The field must contain a value. If left empty, the rule fails. | | **Blank** | The field must be empty. If a value is entered, the rule fails. | | **Data Pattern** | The field value must match the selected regex pattern. Requires a Pattern Name to be selected. | | **Range Expression** | The field value must satisfy the selected numeric range. Requires a Pattern Name to be selected. | > [!NOTE] > **Note** **Mandatory** and **Blank** validation types do not require a Pattern Name. **Data Pattern** and **Range Expression** require a matching pattern to already exist in the **Validation Patterns Setup** page (see [Configure Data Patterns](/business-central/docs/bc-configure-data-patterns)). #### **Outcome options** | **Outcome** | **Behaviour** | | --- | --- | | **Default Error** | Shows a standard blocking error. D365 BC shows its standard hardcoded error message. You do not need to enter a **Validation Message**. The user cannot save the record until the issue is resolved. | | **Custom Warning** | Shows a warning. User can continue. D365 BC shows the message you enter in **Validation Message** as a non-blocking popup. The user can click **OK** to acknowledge and proceed without fixing the value. | | **Custom Error** | D365 BC shows the message you enter in **Validation Message** as a blocking error. The user cannot save the record until the issue is resolved. | > [!NOTE] > **Note** For **Custom Warning** and **Custom Error**, the **Validation Message** field is required. Write a clear, actionable message so that end users understand what value is expected (for example: *"E-mail must follow the format: name@domain.com"*). **Save the rule** D365 BC saves the row automatically when you move to the next row or close the page. Return to the **Data Policy** form, the **No. of Validation Rules** count for the field will have increased. ### **Configure Data Conditions (conditional rules)** A **Data Condition** restricts when a validation rule fires. If no conditions are defined, the rule always fires when the field is touched. If one or more conditions are defined, the rule only fires when **all active conditions are met**. This is useful for requirements such as: *"Payment Terms Code is mandatory, but only for Customers whose Country/Region Code is US."* **Select the validation rule to add a condition to** 1. On the **Data Validations** page, select the rule row you want to make conditional. 2. Scroll down to the **Data Conditions** sub-panel at the bottom of the page. The **Data Conditions** panel shows: | **Field** | **Description** | | --- | --- | | **Description** | A label for this condition line | | **Enable Condition** | Toggle that determines whether the condition is active | | **No. of Filter Values** | How many filter values are defined for this condition | **Add a condition line** 1. In the **Data Conditions** sub-panel, click **New Line**. 2. Enter a **Description** for the condition (for example: *"Country = US"*). 3. Set **Enable Condition** to on (enabled). **Define the filter values for the condition** 1. With the condition row selected, click the **Filters** action (in the **Data Conditions** sub-panel action bar). 2. The filter definition page opens. For each filter: - Select the **Filter Field** (for example, **Country/Region Code** - field 12). - The **Filter Field Name** is auto-populated. - Enter the **Filter Value** (for example, **US**). - Set **Active** = Yes. 3. Close the filter page. The **No. of Filter Values** on the condition row updates to reflect the number of filter values entered. > [!NOTE] > **Note: AND vs OR logic:** Multiple filter values on the same condition line follow **AND** logic, meaning all filter criteria must be met for the condition to be satisfied. To achieve **OR** logic, create separate condition lines. If the filters in Anywhere Mobility Solutions one condition line are met, the rule is triggered. > > *Example:* To make a field mandatory for both US and CA customers, create two condition lines, then one with **Country** = US and one with **Country** = CA. If either condition is met, the validation is applied. **Verify the condition is active** Confirm that the **Enable Condition** toggle is turned on for the condition row. Anywhere Mobility Solutions condition lines where the toggle is turned off are ignored, and the rule behaves as if those conditions do not exist. ### **Examples** **Example 1 - Mandatory field, always enforced** *Scenario:* Every customer must have a Phone No. before the record can be saved. | **Field** | **Value** | | --- | --- | | Validation Type | Mandatory | | Outcome | Custom Error | | Validation Message | "Phone No. is required for all customers." | No **Data Condition** needed, this rule is triggeerd every time a Customer record is saved or when the user leaves the **Phone No.** field empty. **What the user sees:** A red error message reads *"Phone No. is required for all customers."* The record cannot be saved until a value is entered. **Example 2 - Email format validation** *Scenario:* Customer email addresses must follow a valid email format. | **Field** | **Value** | | --- | --- | | Validation Type | Data Pattern | | Pattern Name | Email Address | | Outcome | Custom Error | | Validation Message | "E-mail must follow the format: name@domain.com" | The **Email Address** pattern must exist in **Validation Patterns Setup** before selecting it here (see [Configure Data Patterns](/business-central/docs/bc-configure-data-patterns)). **What passes:** `john.smith@company.com`, `info@staedean.com` **What fails:** `john.smith`, `@company.com`, `john smith at company dot com` **What the user sees when it fails:** *"E-mail must follow the format: name@domain.com"*. A red error message is displayed, and the record cannot be saved. **Example 3 - Range check on Credit Limit** **Scenario***:* Customer credit limits must always be between 500 and 2,500. Values outside this range must be rejected. | **Field** | **Value** | | --- | --- | | Validation Type | Range Expression | | Pattern Name | *Create a pattern with format* `500..2500` *(see Section 4.5)* | | Outcome | Custom Error | | Validation Message | "Credit Limit must be between 500 and 2,500." | **What passes:** 500, 1000, 2500 **What fails:** 0, 499, 2501, 10000 **What the user sees when it fails:** *"Credit Limit must be between 500 and 2,500."*. A red error message is displayed, and the record cannot be saved until a value within the specified range is entered. **Example 4 - Non-blocking advisory warning** **Scenario***:* Bank Account No. should be filled in for vendors, but the team wants to allow records to be saved without it while still alerting the user. | **Field** | **Value** | | --- | --- | | Validation Type | Mandatory | | Outcome | Custom Warning | | Validation Message | "Bank Account No. is missing. Please add it before the vendor's first payment run." | **What the user sees:** A popup dialogue with the warning message and an **OK** button. The user can click **OK** to acknowledge the message, and the record is saved without being blocked. **Example 5 - Mandatory field with condition (Country = US)** **Scenario***:* Payment Terms Code must be filled in only for customers in the United States. For all other countries, this field remains optional. | **Field** | **Value** | | --- | --- | | Validation Type | Mandatory | | Outcome | Custom Error | | Validation Message | "Payment Terms Code is required for US customers." | Data Condition: | **Condition field** | **Value** | | --- | --- | | Description | Country = US | | Enable Condition | On | | Filter Field | Country/Region Code | | Filter Value | US | | Active | Yes | **What the user sees when Country/Region Code = US and Payment Terms Code is blank:** *"Payment Terms Code is required for US customers."* A red error message is displayed, and the record cannot be saved. **When Country/Region Code = DE, GB, or anything other than US:** the rule is skipped, and no error or warning is shown. **Example 6 - Blank field with condition (Contact Type = Person)** **Scenario***:* On the Contact table, the **Company Name** field must be left blank when the contact's **Type** is **Person**. A person contact should not have a company name entered, as this can cause issues in downstream reporting. | **Field** | **Value** | | --- | --- | | Validation Type | Blank | | Outcome | Custom Error | | Validation Message | "Company Name must be empty when the contact is a Person. Use the Company Name field on the Company contact instead." | **Data Condition:** | **Condition field** | **Value** | | --- | --- | | Description | Type = Person | | Enable Condition | On | | Filter Field | Type | | Filter Value | Person | | Active | Yes | **What the user sees when Type = Person and a value is entered in Company Name:** A custom error message is displayed, and the record cannot be saved. **When Type = Company:** The rule is skipped, and the **Company Name** field can be entered.