> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Validate Preset String • AI Agent SDK

> validate_preset_string: Raise a helpful error when a string does not name a known preset.

# validate\_preset\_string

<div className="flex items-center gap-2">
  <Badge color="teal">Function</Badge>
</div>

> This function is defined in the [**parse\_utils**](../modules/parse_utils) module.

Raise a helpful error when a string does not name a known preset.

Non-string values pass through untouched, so callers can hand this the raw
parameter without pre-checking the type. Matching is case-insensitive,
ignores surrounding whitespace, and treats `-`/`_` as interchangeable,
mirroring the preset lookups performed by the parameter resolvers (e.g.
`PermissionMode.resolve` accepts both `accept_edits` and
`accept-edits`). This keeps the guard from rejecting spellings the
downstream resolver would happily accept.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def validate_preset_string(param_name: str, value: Any, presets: Iterable[str]) -> None
```

## Parameters

<ParamField query="param_name" type="str" required={true}>
  Name of the parameter (for the error message)
</ParamField>

<ParamField query="value" type="Any" required={true}>
  Raw parameter value
</ParamField>

<ParamField query="presets" type="Iterable[str]" required={true}>
  Valid preset names
</ParamField>

### Exceptions

<AccordionGroup>
  <Accordion title="ValueError">
    If value is a string that is not a known preset
  </Accordion>
</AccordionGroup>

## Uses

* `canonical_preset_key`
* `make_preset_error`

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/config/parse_utils.py#L209">
  `praisonaiagents/config/parse_utils.py` at line 209
</Card>
