***

title: validate
slug: /reference/typescript/agents/context-builder/validate
description: Validate the entire context configuration tree.
max-toc-depth: 3
---------------------

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

Validate the entire context configuration. Called automatically during SWML
rendering, but can be called manually to catch errors early.

Checks performed:

* At least one context exists.
* A single context is named `"default"`.
* Every context has at least one step.
* All context-level `valid_contexts` references point to contexts that exist in the builder.
* All `gather_info` `completion_action` targets point to valid steps.

## **Returns**

`void` -- Throws `Error` with a descriptive message if validation fails.

## **Example**

```typescript {8}
import { ContextBuilder } from '@signalwire/sdk';

const builder = new ContextBuilder();
const ctx = builder.addContext('default');
ctx.addStep('greet').setText('Hello!');

try {
  builder.validate();
} catch (e) {
  console.log(`Invalid context config: ${e}`);
}
```