# Min Length Check Examples

Source: https://userguide.qualytics.io/data-quality-checks/min-length/deep-dive/examples/

Three real-world scenarios that show how the Min Length check is typically used in production: guarding a product code, requiring a usable justification with a filter, and auditing a legacy identifier mid-cleanup. The first two run at 100% coverage and report Record Anomalies; the third lowers coverage and reports a Shape Anomaly instead.

**Tab: Product Code Floor**

**The situation:** Product codes in the catalog are always at least six characters. Shorter values come from a partner feed that sends internal abbreviations, and they never match anything in the master catalog.

**Check configuration**

| Field | Value |
| --- | --- |
| Rule | Min Length |
| Field | `product_code` |
| Filter | *(none)* |
| Custom Anomaly Description | Off |
| Length | `6` |
| Array Element Context | Off |
| Coverage | 100% |
| Owner | *(check creator)* |
| Anomaly Assignee | *(Catalog Data team)* |
| Description | Product code must be at least 6 characters. |
| Tags | `catalog`, `format` |
| Additional Metadata | `jira: DATA-8701` |
| Status | Active |

**Payload**

```json
{
    "description": "Product code must be at least 6 characters.",
    "rule": "minLength",
    "fields": ["product_code"],
    "container_id": 145,
    "coverage": 1,
    "filter": null,
    "properties": {"value": 6},
    "tags": ["catalog", "format"],
    "additional_metadata": {"jira": "DATA-8701"},
    "anomaly_message_field": null,
    "template_id": null,
    "status": "Active",
    "owner_id": 7,
    "default_anomaly_assignee_id": 12
}
```

**Sample Data**

| item_id | product_code | supplier |
| --- | --- | --- |
| I-001 | SKU-4471 | acme |
| I-002 | A12 | partner |
| I-003 | SKU-9930 | acme |
| I-004 | *(null)* | partner |

**What gets flagged**

Item `I-002` holds a three-character abbreviation from the partner feed. `I-004` is NULL and passes without firing an anomaly. Coverage is 100%, so the failing row is reported as a Record Anomaly, naming the value and the limit it breaks.

> **Example: Record Anomaly**
>
> product_code has the value A12, which is shorter than the minimum of 6

**Flowchart**

```mermaid
graph TD
    A["No filter, evaluate all rows"] --> B["Read product_code"]
    B --> C{"Is value NULL?"}
    C -->|Yes| D["Row passes"]
    C -->|No| E{"Is the length >= 6?"}
    E -->|Yes| D
    E -->|No| F["Flag row.<br/>Record Anomaly per failing row."]
```

**Equivalent SQL**

```sql
-- Rows the Min Length check would flag.
SELECT i.*
FROM items i
WHERE i.product_code IS NOT NULL
  AND length(i.product_code) < 6;
```

**Tab: Usable Justification with Filter**

**The situation:** Refunds above the approval threshold require a written justification of at least 20 characters. Entries like `ok` or `-` satisfy a Not Null check but tell a reviewer nothing. Refunds below the threshold do not require one.

**Check configuration**

| Field | Value |
| --- | --- |
| Rule | Min Length |
| Field | `justification` |
| Filter | `amount > 1000` |
| Custom Anomaly Description | Off |
| Length | `20` |
| Array Element Context | Off |
| Coverage | 100% |
| Owner | *(check creator)* |
| Anomaly Assignee | *(Finance Controls)* |
| Description | High-value refunds must carry a usable justification. |
| Tags | `finance`, `governance` |
| Additional Metadata | `jira: DATA-8744` |
| Status | Active |

**Payload**

```json
{
    "description": "High-value refunds must carry a usable justification.",
    "rule": "minLength",
    "fields": ["justification"],
    "container_id": 512,
    "coverage": 1,
    "filter": "amount > 1000",
    "properties": {"value": 20},
    "tags": ["finance", "governance"],
    "additional_metadata": {"jira": "DATA-8744"},
    "anomaly_message_field": null,
    "template_id": null,
    "status": "Active",
    "owner_id": 7,
    "default_anomaly_assignee_id": 29
}
```

**Sample Data** (filtered to `amount > 1000`)

| refund_id | amount | justification |
| --- | --- | --- |
| RF-01 | 2400 | Duplicate charge confirmed with the acquirer |
| RF-02 | 1800 | ok |
| RF-03 | 5200 | Customer returned the damaged unit |

**Why the filter matters**

The filter runs **before** the measurement, so small refunds are never tested against the justification rule. Only high-value refunds are evaluated.

**What gets flagged**

`RF-02` carries a two-character placeholder, which passes a presence check but not a usability one. Coverage is 100%, so the failure is reported as a Record Anomaly, and the message names the filter that scoped the evaluation.

> **Example: Record Anomaly**
>
> justification has the value ok, which is shorter than the minimum of 20 (applied to records where amount > 1000)

**Flowchart**

```mermaid
graph TD
    A["Apply filter: amount > 1000"] --> B["Read justification"]
    B --> C{"Is the length >= 20?"}
    C -->|Yes| D["Row passes"]
    C -->|No| E["Flag row.<br/>Message names the filter:<br/>applied to records where amount > 1000"]
```

**Equivalent SQL**

```sql
-- Rows the check would flag among high-value refunds.
SELECT r.*
FROM refunds r
WHERE r.amount > 1000
  AND r.justification IS NOT NULL
  AND length(r.justification) < 20;
```

**Tab: Legacy Identifier Mid-Cleanup**

**The situation:** A legacy `external_ref` column holds truncated identifiers from an old import. A backfill is restoring the full values, so a small fraction of short rows is expected and the check tolerates up to 0.5% failures.

**Check configuration**

| Field | Value |
| --- | --- |
| Rule | Min Length |
| Field | `external_ref` |
| Filter | *(none)* |
| Custom Anomaly Description | Off |
| Length | `10` |
| Array Element Context | Off |
| Coverage | 99.5% |
| Owner | *(check creator)* |
| Anomaly Assignee | *(Legacy Migration team)* |
| Description | External reference must be at least 10 characters. |
| Tags | `legacy`, `format` |
| Additional Metadata | `jira: DATA-8788` |
| Status | Active |

**Payload**

```json
{
    "description": "External reference must be at least 10 characters.",
    "rule": "minLength",
    "fields": ["external_ref"],
    "container_id": 733,
    "coverage": 0.995,
    "filter": null,
    "properties": {"value": 10},
    "tags": ["legacy", "format"],
    "additional_metadata": {"jira": "DATA-8788"},
    "anomaly_message_field": null,
    "template_id": null,
    "status": "Active",
    "owner_id": 7,
    "default_anomaly_assignee_id": 41
}
```

**Sample Data**

| record_id | external_ref | backfilled |
| --- | --- | --- |
| X-01 | EXT-99213004 | true |
| X-02 | EXT-9 | false |
| X-03 | 99 | false |
| X-04 | *(null)* | false |

**What gets flagged**

Records `X-02` and `X-03` still hold truncated identifiers. `X-04` is NULL, so it passes without firing an anomaly but still counts in the scanned total. Only 50% of the rows pass, which is below the 99.5% coverage threshold, so the check reports a single Shape Anomaly for the dataset with a sample of the offending rows. Coverage below 100% does not produce Record Anomalies.

> **Example: Shape Anomaly**
>
> external_ref values are shorter than the minimum of 10, affecting 2 of 4 asserted records

**Flowchart**

```mermaid
graph TD
    A["No filter, evaluate all rows"] --> B["Read external_ref"]
    B --> C{"Is value NULL?"}
    C -->|Yes| D["Row passes"]
    C -->|No| E{"Is the length >= 10?"}
    E -->|Yes| D
    E -->|No| F["Flag row.<br/>Passing rate falls below the 99.5%<br/>coverage, so one Shape Anomaly is reported."]
```

**Equivalent SQL**

```sql
-- Rows the check would flag.
SELECT x.*
FROM external_records x
WHERE x.external_ref IS NOT NULL
  AND length(x.external_ref) < 10;
```

## See Also

- **How It Works**

  The complete reference: definition, field scope, the length property, NULL handling, arrays, filter behavior, and coverage.

  [How It Works](https://userguide.qualytics.io/data-quality-checks/min-length/deep-dive/how-it-works/)
- **Anomaly Reporting**

  The anomaly messages the check produces, what the numbers mean, Source Records highlighting, and Custom Anomaly Description.

  [Anomaly Reporting](https://userguide.qualytics.io/data-quality-checks/min-length/deep-dive/anomaly-reporting/)
- **Best Practices**

  Guidelines for choosing the length, pairing rules, and keeping the signal clean.

  [Best Practices](https://userguide.qualytics.io/data-quality-checks/min-length/deep-dive/best-practices/)
- **Permissions**

  The team permission each action needs: view, create, edit, archive, restore, and delete.

  [Permissions](https://userguide.qualytics.io/data-quality-checks/min-length/deep-dive/permissions/)

*Last updated: September 22, 2026.*
