---
title: Pattern Matching
description: Validates data values against one or more specified regular expression patterns.
group: Validity
---

# Pattern Matching

The **Pattern Matching** rule validates whether data values in a specified column match one or more defined regular expression patterns.  
This rule is commonly used to:

- Validate standard formats such as emails, phone numbers, or codes  
- Enforce consistent data entry formats  
- Verify compliance with business rules for field patterns  

**Example Usage**:  
- Check that all phone numbers follow international or US formats  
- Ensure email addresses are valid and properly structured  
- Validate password or ID formats against custom regex patterns  

## Configuration Fields  

### Rule-Specific Configuration  

| Field Name       | Description                                            | Required | Data Type / Options |
|:----------------|:--------------------------------------------------------|:-----------|:--------------------|
| **Pattern**         | Regular expressions to validate against                 | Yes        | Array of Strings (`String[]`) |

---

### Success Criteria Configuration  

This section defines how the rule’s outcome is measured against expected thresholds.

| Field Name        | Description                                                 | Required   | Options / Format                                                     |
|:------------------|:------------------------------------------------------------|:-----------|:----------------------------------------------------------------------|
| **Operator**        | Comparison operation for the result count                   | Yes        | `GreaterThan`, `LessThan`, `EqualTo`, `Between`                      |
| **Threshold Value** | Value for comparison (single value for most operators)      | Conditional| Number                                                               |
| **Threshold Min**   | Minimum value (for `Between` operator)                      | Conditional| Number                                                               |
| **Threshold Max**   | Maximum value (for `Between` operator)                      | Conditional| Number                                                               |
| **Is Percentage**   | Whether the threshold represents a percentage or count      | No         | `true` / `false` (default: `false`)                                  |
| **Allow Nulls**     | Should null values be treated as valid                      | No         | `true` / `false` (default: `false`)                                  |
| **Check For Match** | When `false`, validates for negation of the condition       | No         | `true` / `false` (default: `true`)                                   |

---

## Sample Input Data  

| ID | Phone Number     | Email              |
|:----|:-----------------|:-------------------|
| 1  | 415-555-1234     | john@example.com   |
| 2  | +44 20 7946 0958 | NULL               |
| 3  | (650) 555-1234   | sarah@test.org     |
| 4  | NULL             | invalid-email      |
| 5  | 12345            | admin@company.com  |

---

## Sample Configurations  

### Example 1: Phone Number Pattern Validation  



| Configuration Field | Value                        |
|:---------------------|:------------------------------|
| Column                | Phone Number                 |
| Patterns              | `^\+\d{1,3} \d{2,4} \d{4} \d{4}$`,<br>`^\(\d{3}\) \d{3}-\d{4}$`,<br>`^\d{3}-\d{3}-\d{4}$` |
| Operator              | GreaterThan                  |
| Threshold Value       | 3                            |
| Is Percentage         | false                         |
| Allow Nulls           | true                         |
| Check For Match       | true                         |

**Explanation**:  
Ensures that phone numbers match either international or US formats. At least 3 matches are required for the rule to pass. Null values are allowed.

---

### Example 2: Email Address Pattern Validation  



| Configuration Field | Value                        |
|:---------------------|:------------------------------|
| Column                | Email                        |
| Patterns              | `^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$` |
| Operator              | EqualTo                      |
| Threshold Value       | 3                            |
| Is Percentage         | false                         |
| Allow Nulls           | false                         |
| Check For Match       | true                          |

**Explanation**:  
Validates that email addresses follow a standard pattern and that at least 3 records must match. Nulls are treated as invalid.

---

## Sample Output  

| Column Name   | Rule Name         | Success Count | Failure Count | Null Count | Within Threshold |
|:---------------|:-------------------|:---------------|:---------------|:------------|:------------------|
| Phone Number  | Pattern Matching   | 4             | 1             | 0          | Yes              |
| Email         | Pattern Matching   | 3             | 1             | 1          | Yes              |

---
