# Is Credit Card Check Examples

Source: https://userguide.qualytics.io/data-quality-checks/is-credit-card/deep-dive/examples/

Three real-world scenarios that show how the Is Credit Card check is typically used in production: validating a dedicated card column, checking card-method 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.

**Tab: Dedicated Card Column**

**The situation:** The `card_number` column exists to hold nothing but the card number. Rows holding a token, a note, or a truncated value break the file the platform submits to the acquirer.

**Check configuration**

| Field | Value |
| --- | --- |
| Rule | Is Credit Card |
| Field | `card_number` |
| Filter | *(none)* |
| Custom Anomaly Description | Off |
| Coverage | 100% |
| Owner | *(check creator)* |
| Anomaly Assignee | *(Payments Engineering)* |
| Description | Card number column must hold valid card numbers. |
| Tags | `payments`, `format` |
| Additional Metadata | `jira: DATA-9301` |
| Status | Active |

**Payload**

```json
{
    "description": "Card number column must hold valid card numbers.",
    "rule": "isCreditCard",
    "fields": ["card_number"],
    "container_id": 301,
    "coverage": 1,
    "filter": null,
    "properties": {},
    "tags": ["payments", "format"],
    "additional_metadata": {"jira": "DATA-9301"},
    "anomaly_message_field": null,
    "template_id": null,
    "status": "Active",
    "owner_id": 7,
    "default_anomaly_assignee_id": 15
}
```

**Sample Data**

| payment_id | card_number | method |
| --- | --- | --- |
| P-001 | 4111 1111 1111 1111 | card |
| P-002 | tok_1H8sK2 | card |
| P-003 | 5500-0000-0000-0004 | card |
| P-004 | *(null)* | card |

**What gets flagged**

Payment `P-002` holds a vault token instead of a number. `P-003` uses dashes between digit groups and passes. `P-004` is NULL and passes without firing an anomaly. Coverage is 100%, so the failing row is reported as a Record Anomaly.

> **Example: Record Anomaly**
>
> card_number has the value tok_1H8sK2, which is not a valid credit card number

**Flowchart**

```mermaid
graph TD
    A["No filter, evaluate all rows"] --> B["Read card_number"]
    B --> C{"Is value NULL?"}
    C -->|Yes| D["Row passes"]
    C -->|No| E{"Strip spaces and dashes:<br/>all digits and Luhn valid?"}
    E -->|Yes| D
    E -->|No| F["Flag row.<br/>Record Anomaly per failing row."]
```

**Equivalent SQL**

```sql
-- Rows the Is Credit Card check would flag.
SELECT p.*
FROM payments p
WHERE p.card_number IS NOT NULL
  AND NOT luhn_valid(replace(replace(p.card_number, ' ', ''), '-', ''));
```

> **Note: Require a value too**
>
> NULL values pass. Pair the check with [Not Null](https://userguide.qualytics.io/data-quality-checks/not-null/introduction/) on `card_number` when a missing value should also be reported.

**Tab: Card Transactions Only, with Filter**

**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`; other methods hold identifiers of a different shape.

**Check configuration**

| Field | Value |
| --- | --- |
| Rule | Is 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 valid card number. |
| Tags | `payments`, `format` |
| Additional Metadata | `jira: DATA-9333` |
| Status | Active |

**Payload**

```json
{
    "description": "Card transactions must carry a valid card number.",
    "rule": "isCreditCard",
    "fields": ["instrument"],
    "container_id": 302,
    "coverage": 1,
    "filter": "method = 'card'",
    "properties": {},
    "tags": ["payments", "format"],
    "additional_metadata": {"jira": "DATA-9333"},
    "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 | **** 1881 |
| T-03 | card | 6011000000000004 |

**Why the filter matters**

The filter runs **before** the evaluation, so transfers and vouchers are never validated as cards. Only card transactions are evaluated.

**What gets flagged**

`T-02` holds a masked value, which no longer contains a full number. 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**
>
> instrument has the value **** 1881, which is not a valid credit card number (applied to records where method = 'card')

**Flowchart**

```mermaid
graph TD
    A["Apply filter: method = 'card'"] --> B["Read instrument"]
    B --> C{"Is the whole value<br/>a card number?"}
    C -->|Yes| D["Row passes"]
    C -->|No| E["Flag row.<br/>Message names the filter:<br/>applied to records where method = 'card'"]
```

**Equivalent SQL**

```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 NOT luhn_valid(replace(replace(t.instrument, ' ', ''), '-', ''));
```

**Tab: Legacy Column Mid-Cleanup**

**The situation:** A legacy wallet table mixes real numbers with free text in `stored_card`. A cleanup job is rewriting the bad rows, and a small fraction is expected to remain broken until it finishes, so the check tolerates up to 0.5% failures.

**Check configuration**

| Field | Value |
| --- | --- |
| Rule | Is 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 valid card numbers. |
| Tags | `legacy`, `payments` |
| Additional Metadata | `jira: DATA-9388` |
| Status | Active |

**Payload**

```json
{
    "description": "Stored card column must hold valid card numbers.",
    "rule": "isCreditCard",
    "fields": ["stored_card"],
    "container_id": 303,
    "coverage": 0.995,
    "filter": null,
    "properties": {},
    "tags": ["legacy", "payments"],
    "additional_metadata": {"jira": "DATA-9388"},
    "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 | 4111 1111 1111 1112 | false |
| W-04 | *(null)* | false |

**What gets flagged**

Wallet `W-02` holds free text and `W-03` holds a number whose Luhn checksum does not come out to zero. `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.

> **Example: Shape Anomaly**
>
> stored_card values are not a valid credit card number, affecting 2 of 4 asserted records

**Flowchart**

```mermaid
graph TD
    A["No filter, evaluate all rows"] --> B["Read stored_card"]
    B --> C{"Is value NULL?"}
    C -->|Yes| D["Row passes"]
    C -->|No| E{"Strip spaces and dashes:<br/>all digits and Luhn valid?"}
    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 w.*
FROM wallets w
WHERE w.stored_card IS NOT NULL
  AND NOT luhn_valid(replace(replace(w.stored_card, ' ', ''), '-', ''));
```

> **Warning: A short all-digit value would pass**
>
> A truncated value such as `0000` satisfies Luhn and is not reported. Pair the check with [Min Length](https://userguide.qualytics.io/data-quality-checks/min-length/introduction/) when truncation is the failure you are hunting.

## See Also

- **How It Works**

  The complete reference: definition, field scope, validation semantics, NULL handling, arrays, filter behavior, and coverage.

  [How It Works](https://userguide.qualytics.io/data-quality-checks/is-credit-card/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/is-credit-card/deep-dive/anomaly-reporting/)
- **Best Practices**

  Guidelines for choosing the right column, handling masked values, pairing rules, and keeping the signal clean.

  [Best Practices](https://userguide.qualytics.io/data-quality-checks/is-credit-card/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/is-credit-card/deep-dive/permissions/)

*Last updated: October 19, 2026.*
