## EditValidation


Edit an existing validation plan with a plain-English instruction using an LLM.


Usage

``` python
EditValidation(
    validation,
    instruction,
    model,
    data=None,
    api_key=None,
    verify_ssl=True,
    max_reprompts=1
)
```


While <a href="DraftValidation.html#pointblank.DraftValidation" class="gdls-link"><code>DraftValidation</code></a> generates a validation plan from scratch by profiling a table, [EditValidation](EditValidation.md#pointblank.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 <a href="EditValidation.html#pointblank.EditValidation.accept" class="gdls-link"><code>accept()</code></a> it before anything runs, keeping a human in control.

[EditValidation](EditValidation.md#pointblank.EditValidation) reuses the same provider abstraction as [DraftValidation](DraftValidation.md#pointblank.DraftValidation) (via the `chatlas` package), supporting the `"anthropic"`, `"openai"`, `"ollama"`, `"bedrock"`, and `"azure-openai"` providers. Install the optional requirements with `pip install pointblank[generate]`.

> **Warning: Warning**
>
> The [EditValidation](EditValidation.md#pointblank.EditValidation) class is experimental. Please report any issues you encounter in the [Pointblank issue tracker](https://github.com/posit-dev/pointblank/issues).


## Parameters


`validation: Any`  
The existing validation plan to edit. This can be a <a href="Validate.html#pointblank.Validate" class="gdls-link"><code>Validate</code></a> object, a Python code string (such as the output of <a href="Validate.to_code.html#pointblank.Validate.to_code" class="gdls-link"><code>Validate.to_code()</code></a>), 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"`, and `"azure-openai"`.

`data: Any = None`  
Optional data table. When provided, a <a href="DataScan.html#pointblank.DataScan" class="gdls-link"><code>DataScan</code></a> 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 <a href="Validate.html#pointblank.Validate" class="gdls-link"><code>Validate</code></a> via <a href="EditValidation.html#pointblank.EditValidation.accept" class="gdls-link"><code>accept()</code></a>.

`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](EditValidation.md#pointblank.EditValidation) object exposing the revised plan through <a href="EditValidation.html#pointblank.EditValidation.to_code" class="gdls-link"><code>to_code()</code></a>, <a href="EditValidation.html#pointblank.EditValidation.diff" class="gdls-link"><code>diff()</code></a>, <a href="EditValidation.html#pointblank.EditValidation.changed_steps" class="gdls-link"><code>changed_steps()</code></a>, and <a href="EditValidation.html#pointblank.EditValidation.accept" class="gdls-link"><code>accept()</code></a>.


## Notes On Data Sent To The Model Provider

As with [DraftValidation](DraftValidation.md#pointblank.DraftValidation), only a JSON summary of the table (generated by [DataScan](DataScan.md#pointblank.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

``` python
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()](#accept) | Execute the revised plan and return the resulting [Validate](Validate.md#pointblank.Validate) object. |
| [changed_steps()](#changed_steps) | Return a structured, step-level list of the changes between the plans. |
| [diff()](#diff) | Return a unified textual diff of the original plan versus the revised plan. |
| [from_plans()](#from_plans) | Build an [EditValidation](EditValidation.md#pointblank.EditValidation) from two known plans, without calling a model. |
| [review()](#review) | Return a `great_tables` GT object summarizing the step-level changes. |
| [to_code()](#to_code) | Return the revised validation plan as Python code. |
| [validate_syntax()](#validate_syntax) | Return whether the revised plan parses and uses only known validation methods. |

------------------------------------------------------------------------


#### accept()


Execute the revised plan and return the resulting [Validate](Validate.md#pointblank.Validate) object.


Usage

``` python
accept(data=None)
```


The returned [Validate](Validate.md#pointblank.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_data` placeholder. If omitted, the `data=` provided to [EditValidation](EditValidation.md#pointblank.EditValidation) is used. One of the two must be present.


##### Returns


`Validate`  
The revised validation plan as a [Validate](Validate.md#pointblank.Validate) object.


------------------------------------------------------------------------


#### changed_steps()


Return a structured, step-level list of the changes between the plans.


Usage

``` python
changed_steps()
```


Unlike <a href="EditValidation.html#pointblank.EditValidation.diff" class="gdls-link"><code>diff()</code></a>, 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

``` python
diff()
```


------------------------------------------------------------------------


#### from_plans()


Build an [EditValidation](EditValidation.md#pointblank.EditValidation) from two known plans, without calling a model.


Usage

``` python
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 <a href="EditValidation.html#pointblank.EditValidation.diff" class="gdls-link"><code>diff()</code></a>, <a href="EditValidation.html#pointblank.EditValidation.changed_steps" class="gdls-link"><code>changed_steps()</code></a>, and <a href="EditValidation.html#pointblank.EditValidation.review" class="gdls-link"><code>review()</code></a>. 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: a <a href="Validate.html#pointblank.Validate" class="gdls-link"><code>Validate</code></a> object, 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 <a href="EditValidation.html#pointblank.EditValidation.review" class="gdls-link"><code>review()</code></a>).


##### Returns


`EditValidation`  
An [EditValidation](EditValidation.md#pointblank.EditValidation) whose `original`/`revised` plans are the ones supplied, ready for <a href="EditValidation.html#pointblank.EditValidation.diff" class="gdls-link"><code>diff()</code></a>, <a href="EditValidation.html#pointblank.EditValidation.changed_steps" class="gdls-link"><code>changed_steps()</code></a>, <a href="EditValidation.html#pointblank.EditValidation.review" class="gdls-link"><code>review()</code></a>, and <a href="EditValidation.html#pointblank.EditValidation.accept" class="gdls-link"><code>accept()</code></a>.


##### Examples

``` python
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

``` python
review()
```


This renders the added, removed, and modified steps side by side for quick human review before accepting the edit. It pairs with <a href="EditValidation.html#pointblank.EditValidation.accept" class="gdls-link"><code>accept()</code></a>: review the change, then accept it.


##### Returns


`GT`  
A `great_tables` table with one row per changed step.


------------------------------------------------------------------------


#### to_code()


Return the revised validation plan as Python code.


Usage

``` python
to_code()
```


------------------------------------------------------------------------


#### validate_syntax()


Return whether the revised plan parses and uses only known validation methods.


Usage

``` python
validate_syntax()
```
