EditValidation
Edit an existing validation plan with a plain-English instruction using an LLM.
Usage
EditValidation(
validation,
instruction,
model,
data=None,
api_key=None,
verify_ssl=True,
max_reprompts=1
)While DraftValidation generates a validation plan from scratch by profiling a table, EditValidation takes an existing plan plus a natural-language instruction (e.g., “add a freshness check on updated_at, tighten the email regex, and drop the price > 0 check”) and produces a revised plan. You review the change as a diff and explicitly accept() it before anything runs, keeping a human in control.
EditValidation reuses the same provider abstraction as DraftValidation (via the chatlas package), supporting the "anthropic", "openai", "ollama", "bedrock", and "azure-openai" providers. Install the optional requirements with pip install pointblank[generate].
The EditValidation class is experimental. Please report any issues you encounter in the Pointblank issue tracker.
Parameters
validation: Any-
The existing validation plan to edit. This can be a
Validateobject, a Python code string (such as the output ofValidate.to_code()), a YAML configuration string, or a path to a.pyor.yaml/.ymlfile. All inputs are normalized to Pointblank code before being sent to the model. instruction: str-
A plain-English description of the changes to make to the plan.
model: str-
The model to be used. This should be in the form of
provider:model(e.g.,"anthropic:claude-opus-4-8"). Supported providers are"anthropic","openai","ollama","bedrock", and"azure-openai". data: Any = None-
Optional data table. When provided, a
DataScansummary of the table is included in the prompt so the model can make informed edits (e.g., tightening a range using observed min/max values). It is also used as the default data source when building aValidateviaaccept(). api_key: str | None = None-
The API key to be used for the model.
verify_ssl: bool = True-
Whether to verify SSL certificates when making requests to the LLM provider. Defaults to
True. Use with caution as disabling SSL verification can pose security risks. max_reprompts: int = 1-
The maximum number of times to automatically re-prompt the model when the returned code fails the syntax/lint check, before surfacing the result to the user. Defaults to
1.
Returns
EditValidation-
An EditValidation object exposing the revised plan through
to_code(),diff(),changed_steps(), andaccept().
Notes On Data Sent To The Model Provider
As with DraftValidation, only a JSON summary of the table (generated by DataScan) is ever sent to the model, never the underlying rows. If data= is omitted, no table information is sent at all; the model edits the plan using only the plan code and your instruction.
Examples
import pointblank as pb
# An existing plan
validation = (
pb.Validate(data=pb.load_dataset("small_table"))
.col_vals_gt(columns="d", value=100)
.col_vals_regex(columns="b", pattern="[0-9]-[a-z]{3}")
)
# Edit it with a plain-English instruction
edited = pb.EditValidation(
validation=validation,
instruction="Loosen the `d` check to value=50 and add a not-null check on column `a`.",
model="anthropic:claude-opus-4-8",
data=pb.load_dataset("small_table"),
)
print(edited.diff()) # review the change
plan = edited.accept() # a Validate you can .interrogate()Methods
| Name | Description |
|---|---|
| accept() | Execute the revised plan and return the resulting Validate object. |
| changed_steps() | Return a structured, step-level list of the changes between the plans. |
| diff() | Return a unified textual diff of the original plan versus the revised plan. |
| from_plans() | Build an EditValidation from two known plans, without calling a model. |
| review() |
Return a great_tables GT object summarizing the step-level changes.
|
| to_code() | Return the revised validation plan as Python code. |
| validate_syntax() | Return whether the revised plan parses and uses only known validation methods. |
accept()
Execute the revised plan and return the resulting Validate object.
Usage
accept(data=None)The returned Validate has NOT been interrogated; call .interrogate() on it to run the validation.
Parameters
data: Any = None-
The data table to bind to the plan’s
your_dataplaceholder. If omitted, thedata=provided to EditValidation is used. One of the two must be present.
Returns
Validate- The revised validation plan as a Validate object.
changed_steps()
Return a structured, step-level list of the changes between the plans.
Usage
changed_steps()Unlike diff(), which is a textual diff sensitive to formatting, this compares the two plans at the level of validation steps and is robust to reformatting. Each entry is a dict with an "action" of "add", "remove", or "modify", a "method" name, and the relevant "old"/"new" step text.
Returns
list[dict]-
One record per changed step, e.g.
[{"action": "modify", "method": "col_vals_gt", "old": "col_vals_gt(columns="d", " "value=100)", "new": "col_vals_gt(columns="d", value=50)"}].
diff()
Return a unified textual diff of the original plan versus the revised plan.
Usage
diff()from_plans()
Build an EditValidation from two known plans, without calling a model.
Usage
from_plans(original, revised, instruction="Manual plan comparison")This is a lightweight way to compare an original plan against a revised one and review the difference with diff(), changed_steps(), and review(). It is useful for reviewing the change between two saved versions of a plan (for example, in code review) and does not require an LLM provider or any API key.
Parameters
original: Any-
The original plan. Accepts anything the
validation=argument accepts: aValidateobject, a code string, a YAML string, or a file path. revised: Any-
The revised plan, in any of the same forms as
original. instruction: str = "Manual plan comparison"-
An optional label describing the comparison (shown as the subtitle in
review()).
Returns
EditValidation-
An EditValidation whose
original/revisedplans are the ones supplied, ready fordiff(),changed_steps(),review(), andaccept().
Examples
import pointblank as pb
v1 = pb.Validate(data=pb.load_dataset("small_table")).col_vals_gt(columns="d", value=100)
v2 = pb.Validate(data=pb.load_dataset("small_table")).col_vals_gt(columns="d", value=50)
comparison = pb.EditValidation.from_plans(v1, v2)
print(comparison.diff())review()
Return a great_tables GT object summarizing the step-level changes.
Usage
review()This renders the added, removed, and modified steps side by side for quick human review before accepting the edit. It pairs with accept(): review the change, then accept it.
Returns
GT-
A
great_tablestable with one row per changed step.
to_code()
Return the revised validation plan as Python code.
Usage
to_code()validate_syntax()
Return whether the revised plan parses and uses only known validation methods.
Usage
validate_syntax()