***

title: validate
slug: /reference/typescript/agents/configuration/schema-utils/validate
description: Validate a SWML document against structural rules.
max-toc-depth: 3
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

Validate a SWML document against structural rules. Checks for required top-level
keys (`version`, `sections`), valid version strings, a `main` section, and correct
AI verb structure. Results are cached.

## **Parameters**

<ParamField path="swml" type="string | Record<string, unknown>" required={true} toc={true}>
  The SWML document as a JSON string or parsed object.
</ParamField>

## **Returns**

`ValidationResult` -- An object with `valid: boolean` and `errors: string[]`.

## **Example**

```typescript {4-7}
import { SchemaUtils } from '@signalwire/sdk';

const schema = new SchemaUtils();
const result = schema.validate({
  version: '1.0.0',
  sections: { main: [{ answer: {} }, { hangup: {} }] },
});

if (!result.valid) {
  console.error('Validation errors:', result.errors);
}
```