Skip to main content

Standard.validate()

Check a single table against the standard.

Usage

Source

Standard.validate(
    data,
    tbl_name=None,
)

This compiles the standard for the table (with to_validate()) and interrogates it. It’s what apply() does for each table it finds, so it’s a quick way to try a standard on one table, or to check a table that’s not part of a source.

Parameters

data: IntoDataFrame

The table to validate. Any table type that Validate takes can be used.

tbl_name: str | None = None
The name of the table, for the validation’s tbl_name=.

Returns

Validate
An interrogated Validate object.

Examples

Let’s try a standard for amount columns on a table of refunds before applying it to a whole warehouse.

import pointblank as pb
import polars as pl

amount_standard = pb.Standard(
    name="amount-columns",
    steps=[
        pb.Step("col_vals_not_null", columns=pb.contains("amount")),
        pb.Step("col_vals_ge", columns=pb.contains("amount"), value=0),
    ],
)

refunds = pl.DataFrame({"refund_id": [1, 2, 3], "refund_amount": [15.0, 0.0, -3.5]})

amount_standard.validate(refunds, tbl_name="refunds")
Pointblank Validation
Standard: amount-columns
Polarsrefunds
STEP COLUMNS VALUES TBL EVAL UNITS PASS FAIL W E C EXT
#4CA64C 1
col_vals_not_null
col_vals_not_null()
refund_amount — ✓ 3 3
1.00
0
0.00
— — — —
#4CA64C66 2
col_vals_ge
col_vals_ge()
refund_amount 0 ✓ 3 2
0.67
1
0.33
— — —

The negative refund fails the second step. The validation is an ordinary interrogated Validate object, so a check like all_passed() works on it as well.