validate

View as MarkdownOpen in Claude

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

1import { ContextBuilder } from '@signalwire/sdk';
2
3const builder = new ContextBuilder();
4const ctx = builder.addContext('default');
5ctx.addStep('greet').setText('Hello!');
6
7try {
8 builder.validate();
9} catch (e) {
10 console.log(`Invalid context config: ${e}`);
11}