Skip to content

Contains Credit Card Check Examples

Three real-world scenarios that show how the Contains Credit Card check is typically used in production: validating a payment reference column, checking card transactions with a filter, and auditing a legacy column 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: A payment integration writes the masked card reference into card_reference. Rows where the column holds a token, a bank slip number, or a note instead of a card number break reconciliation with the acquirer.

Check configuration

Field Value
Rule Contains Credit Card
Field card_reference
Filter (none)
Custom Anomaly Description Off
Coverage 100%
Owner (check creator)
Anomaly Assignee (Payments Engineering)
Description Card reference must hold a credit card number.
Tags payments, format
Additional Metadata jira: DATA-7201
Status Active

Payload

{
    "description": "Card reference must hold a credit card number.",
    "rule": "containsCreditCard",
    "fields": ["card_reference"],
    "container_id": 301,
    "coverage": 1,
    "filter": null,
    "properties": {},
    "tags": ["payments", "format"],
    "additional_metadata": {"jira": "DATA-7201"},
    "anomaly_message_field": null,
    "template_id": null,
    "status": "Active",
    "owner_id": 7,
    "default_anomaly_assignee_id": 15
}

Sample Data

payment_id card_reference method
P-001 4111 1111 1111 1111 card
P-002 boleto-99213 card
P-003 5500-0000-0000-0004 card
P-004 (null) card

What gets flagged

Payment P-002 holds a bank slip identifier where the card number should be. P-004 is NULL and passes without firing an anomaly. Coverage is 100%, so the failing row is reported as a Record Anomaly.

Record Anomaly

The field 'card_reference' has value 'boleto-99213', which does not contain a credit card number

Flowchart

graph TD
    A["No filter, evaluate all rows"] --> B["Read card_reference as text"]
    B --> C{"Is value NULL?"}
    C -->|Yes| D["Row passes"]
    C -->|No| E{"Does it contain<br/>a credit card number?"}
    E -->|Yes| D
    E -->|No| F["Flag row.<br/>Record Anomaly per failing row."]

Equivalent SQL

-- Rows the Contains Credit Card check would flag.
SELECT p.*
FROM payments p
WHERE p.card_reference IS NOT NULL
  AND p.card_reference NOT RLIKE '<credit card pattern>';

The situation: The transactions table mixes card payments with transfers and vouchers. Only rows whose method is card must carry a card number in instrument; the other methods legitimately hold other identifiers.

Check configuration

Field Value
Rule Contains Credit Card
Field instrument
Filter method = 'card'
Custom Anomaly Description Off
Coverage 100%
Owner (check creator)
Anomaly Assignee (Payments Engineering)
Description Card transactions must carry a credit card number.
Tags payments, format
Additional Metadata jira: DATA-7233
Status Active

Payload

{
    "description": "Card transactions must carry a credit card number.",
    "rule": "containsCreditCard",
    "fields": ["instrument"],
    "container_id": 302,
    "coverage": 1,
    "filter": "method = 'card'",
    "properties": {},
    "tags": ["payments", "format"],
    "additional_metadata": {"jira": "DATA-7233"},
    "anomaly_message_field": null,
    "template_id": null,
    "status": "Active",
    "owner_id": 7,
    "default_anomaly_assignee_id": 15
}

Sample Data (filtered to method = 'card')

txn_id method instrument
T-01 card 4012888888881881
T-02 card pending
T-03 card 6011000000000004

Why the filter matters

The filter runs before the evaluation, so transfers and vouchers are never tested for a card number. Only card transactions are evaluated.

What gets flagged

T-02 holds the placeholder pending, so it is the only row reported. 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 'instrument' has value 'pending', which does not contain a credit card number [filter: method = 'card']

Flowchart

graph TD
    A["Apply filter: method = 'card'"] --> B["Read instrument as text"]
    B --> C{"Does it contain<br/>a credit card number?"}
    C -->|Yes| D["Row passes"]
    C -->|No| E["Flag row.<br/>Anomaly message ends with<br/>[filter: method = 'card']"]

Equivalent SQL

-- Rows the check would flag on card transactions.
SELECT t.*
FROM transactions t
WHERE t.method = 'card'
  AND t.instrument IS NOT NULL
  AND t.instrument NOT RLIKE '<credit card pattern>';

The situation: A legacy import left free-text values in stored_card. A cleanup job is rewriting them, and a small fraction is expected to stay broken until it finishes, so the check tolerates up to 0.5% failures.

Check configuration

Field Value
Rule Contains Credit Card
Field stored_card
Filter (none)
Custom Anomaly Description Off
Coverage 99.5%
Owner (check creator)
Anomaly Assignee (Legacy Migration team)
Description Stored card column must hold a credit card number.
Tags legacy, payments
Additional Metadata jira: DATA-7290
Status Active

Payload

{
    "description": "Stored card column must hold a credit card number.",
    "rule": "containsCreditCard",
    "fields": ["stored_card"],
    "container_id": 303,
    "coverage": 0.995,
    "filter": null,
    "properties": {},
    "tags": ["legacy", "payments"],
    "additional_metadata": {"jira": "DATA-7290"},
    "anomaly_message_field": null,
    "template_id": null,
    "status": "Active",
    "owner_id": 7,
    "default_anomaly_assignee_id": 41
}

Sample Data

wallet_id stored_card migrated
W-01 4111111111111111 true
W-02 see contract false
W-03 0000 false
W-04 (null) false

What gets flagged

Wallets W-02 and W-03 still hold free-text and a truncated value. W-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 'stored_card', 50.000% of 4 records (2) do not contain credit card numbers

Flowchart

graph TD
    A["No filter, evaluate all rows"] --> B["Read stored_card as text"]
    B --> C{"Is value NULL?"}
    C -->|Yes| D["Row passes"]
    C -->|No| E{"Does it contain<br/>a credit card number?"}
    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 w.*
FROM wallets w
WHERE w.stored_card IS NOT NULL
  AND w.stored_card NOT RLIKE '<credit card pattern>';

See Also