> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flowforma.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Data validation

> Use the Data validation business rule to check question answers against conditions and RegEx patterns, blocking form submission until values are valid.

This rule lets you validate whether the values entered in a question meet the requirements set in conditions. If the conditions are met, a validation message appears at the bottom of the form and you can't submit it until the information entered is valid.

<img src="https://mintcdn.com/flowforma/29tXFCtk1ynp2c5R/images/product/creating-flows/business-rules/business-rule-types/data-integration-rules/data-validation/data-validation-1.png?fit=max&auto=format&n=29tXFCtk1ynp2c5R&q=85&s=55f06b684e16eee5a9ebb495c651dcdd" alt="Data validation rule configuration" width="618" height="513" data-path="images/product/creating-flows/business-rules/business-rule-types/data-integration-rules/data-validation/data-validation-1.png" />

## Title

The first part of the business rule lets you define a **title** for your rule and select the event on which it operates. The default title is the standard FlowForma rule name; change it by deleting the text and entering your own.

In the **event** field you determine when the rule is executed. You can only add a data validation rule to a question, and only "completed" is available, since the rule runs on step completion.

## Rule actions

* **Enter the error message that will be displayed if the conditions above are met**: enter the message you want displayed when the rule conditions are met.

- **Stop execution**: if stop execution is enabled and this rule is executed, no other rules are executed.
- **Enabled**: rules aren't saved to a list like questions and steps are, so if you want to stop a rule executing without deleting it, toggle this option to enable or disable the rule.
- **Enable audit**: if checked, a record is added to the audit trail when this rule is executed. This option is available when the Compliance feature pack is activated.

## Examples

Data validation works by using conditions to specify answers that are not allowable (invalid) when entered in the question being validated.

* **Equals**: if the value entered in the question selected in the left column **equals** the value in the right column, display a validation message.
* **Not equals**: if the value entered in the question selected in the left column does **not equal** the value in the right column, display a validation message.
* **Is blank**: if the user leaves the question selected in the left column **blank**, display a validation message. (The right column is disabled for **is blank**.)
* **Not blank**: if the user does not leave the question selected in the left column **blank**, display a validation message. (The right column is disabled for **not blank**.)
* **Contains**: if the value entered in the question selected in the left column **contains** the value specified in the right column, display a validation message.
* **Not contains**: if the value entered in the question selected in the left column does **not contain** the value specified in the right column, display a validation message.
* **Greater than**: if the value entered in the question selected in the left column is **greater than** the value specified in the right column, display a validation message. (Numeric values only.)
* **Less than**: if the value entered in the question selected in the left column is **less than** the value specified in the right column, display a validation message. (Numeric values only.)
* **Matches pattern**: if the value entered in the question selected in the left column **matches the pattern** specified in the right column, display a validation message.
* **Does not match pattern**: if the value entered in the question selected in the left column does **not match the pattern** specified in the right column, display a validation message.

## RegEx

Pattern matching is especially useful when combined with a regular expression (RegEx). A RegEx lets you add very complex requirements for the values entered in a question. For example, a regular expression that validates a correctly formatted email address looks like:

```
^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$
```

While RegEx is complex, spending a few minutes searching online will turn up plenty of commonly used, copy-and-pasteable expressions.

RegEx is also useful when you need the user to enter a value in a specific format:

* **03-AG.13**: 2 digits, a hyphen, 2 letters, a dot, then 2 digits: `^[0-9]{2}\-[a-zA-Z]{2}\.[0-9]{2}$`
* **123-456-789**: 3 digits, a hyphen, 3 digits, a hyphen, 3 digits: `^([0-9]{3}-[0-9]{3}-[0-9]{3})$`
