Skip to content

Min Length Check 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.

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

{
    "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, and the message echoes the measured length.

Record Anomaly

The field 'product_code' has value 'A12' (length 3), which is below the minimum length of 6

Flowchart

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

-- 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;

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

{
    "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 ends with the filter that scoped the evaluation.

Record Anomaly

The field 'justification' has value 'ok' (length 2), which is below the minimum length of 20 [filter: amount > 1000]

Flowchart

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/>Anomaly message ends with<br/>[filter: amount > 1000]"]

Equivalent 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;

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

{
    "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.

Shape Anomaly

For the field 'external_ref', 50.000% of 4 records (2) are below the minimum length of 10

Flowchart

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

-- 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