Validate.to_code()
Render this validation plan as canonical Pointblank Python code.
Usage
Validate.to_code()The to_code() method walks the validation plan and reconstructs the equivalent pb.Validate(...).col_vals_*()... method chain as a string. This is the inverse of writing the plan by hand: it takes an in-memory Validate object and produces source code that, when executed, recreates the same plan.
This is useful for sharing a plan, reviewing it in a diff, persisting it alongside results, and it is the foundation for the AI edit/iterate flow (see EditValidation), which sends the current plan to a model as editable code.
Returns
str-
The validation plan as a block of Python code. The data source is rendered as the placeholder
your_data, since the original data variable name is not known to the plan.
Notes On Fidelity
Most validation steps round-trip exactly. Steps that carry non-serializable Python objects, such as pre= preprocessing callables, actions=, callable active= conditions, or the expressions used by col_vals_expr(), conjointly(), and specially(), cannot be reproduced from memory. For those, a syntactically valid placeholder is emitted and a warning is raised so the code still parses and the loss is visible.
Examples
import pointblank as pb
validation = (
pb.Validate(data=pb.load_dataset("small_table"))
.col_vals_gt(columns="d", value=100)
.col_vals_not_null(columns="a")
.rows_distinct()
)
print(validation.to_code())