Edit an existing validation plan with a plain-English instruction using an LLM.
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", "azure-openai", and "cohere" providers. Install the optional requirements with pip install pointblank[generate].
Parameters
validation: Any
-
The existing validation plan to edit. This can be a Validate object, a Python code string (such as the output of Validate.to_code()), a YAML configuration string, or a path to a .py or .yaml/.yml file. 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", "azure-openai", and "cohere".
data: Any = None
-
Optional data table. When provided, a DataScan summary 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 a Validate via accept().
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.
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
Editing a plan with a model needs the chatlas package and an API key, so this first example isn’t run here. We start with a plan for the small_table dataset and ask for two changes:
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}-[0-9]{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()
Nothing runs when the EditValidation object is created, apart from the call to the model. The diff shows the revised plan line by line against the original, and only accept() turns the revised code into a Validate object, using the data= given here because none is passed to accept(). Because data= was given, the model also saw a summary of the table, which helps with edits like choosing a new bound.
The review methods don’t depend on the model, and from_plans() builds an EditValidation from two plans you already have. Here the revised plan makes the same changes that the instruction above asked for:
small_table = pb.load_dataset("small_table")
original = (
pb.Validate(data=small_table)
.col_vals_gt(columns="d", value=100)
.col_vals_regex(columns="b", pattern="[0-9]-[a-z]{3}-[0-9]{3}")
)
revised = (
pb.Validate(data=small_table)
.col_vals_gt(columns="d", value=50)
.col_vals_regex(columns="b", pattern="[0-9]-[a-z]{3}-[0-9]{3}")
.col_vals_not_null(columns="a")
)
edit = pb.EditValidation.from_plans(original, revised, instruction="Loosen d; require a")
edit.review()
| Proposed plan changes |
| Loosen d; require a |
| Change |
Method |
Before |
After |
| ~ modified |
col_vals_gt |
col_vals_gt(columns='d', value=100) |
col_vals_gt(columns='d', value=50) |
| + added |
col_vals_not_null |
|
col_vals_not_null(columns='a') |
The review table lists one row per changed step: the col_vals_gt() step is modified (its value= went from 100 to 50), the col_vals_not_null() step is added, and the unchanged col_vals_regex() step isn’t shown. Once the changes look right, accept() gives the revised plan as a Validate object that’s ready to interrogate.
See Also
- DraftValidation
-
Draft a new validation plan for a table with an LLM.
- to_code()
-
Get a validation plan as Python code.
Functions
| review() |
Return a great_tables GT object summarizing the step-level changes. |
| accept() |
Execute the revised plan and return the resulting Validate object. |
| diff() |
Return a unified textual diff of the original plan versus the revised plan. |
| changed_steps() |
Return a structured, step-level list of the changes between the plans. |
| to_code() |
Return the revised validation plan as Python code. |
| validate_syntax() |
Check whether the revised plan parses and uses only known validation methods. |
| from_plans() |
Build an EditValidation from two known plans, without calling a model. |