Skip to content

Conversation

@rich-iannone
Copy link
Member

@rich-iannone rich-iannone commented Feb 9, 2026

This PR enhances the active= parameter on validation methods, the parameter can now accept a callable in addition to a boolean. When a callable is provided, it is evaluated against the target table before the step runs. If it returns False (or raises an exception), the step is skipped and a descriptive, locale-aware note is attached to the validation report explaining why.

Two new helper functions (has_columns() and has_rows()) provide common pre-check patterns out of the box. Here's an example where several steps are skipped due to various active= parameter inputs:

import polars as pl
import pointblank as pb

my_table = pl.DataFrame({
    "a": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
    "c": [5, 6, 7, 8, 9, 10, 11, 12, 13, 14],
    "revenue": [100, 250, 50, 300, 175, 400, 90, 125, 210, 330],
    "score": [45, 72, 88, 33, 61, 95, 50, 77, 42, 68],
})

validation = (
    pb.Validate(data=my_table)
    .col_vals_gt(
        columns="revenue",
        value=0,
        active=False
    )
    .col_vals_lt(
        columns="score",
        value=100,
        active=pb.has_rows(min=100),  # skip if fewer than 10 rows
    )
    .col_vals_gt(
        columns="c",
        value=pb.col("a"),
        active=lambda tbl: "b" in tbl.columns,  # custom callable
    )
    .interrogate()
)

validation
image

Fixes: #347

@rich-iannone rich-iannone marked this pull request as ready for review February 9, 2026 03:29
@rich-iannone rich-iannone merged commit be8d2bb into main Feb 9, 2026
9 checks passed
@rich-iannone rich-iannone deleted the feat-active-expression branch February 9, 2026 03:30
@phobson
Copy link
Contributor

phobson commented Feb 9, 2026

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Request: add is_active kwarg to checks

2 participants