***

title: SchemaUtils
slug: /reference/typescript/agents/configuration/schema-utils
description: SWML document validation against structural rules with an LRU-style result cache.
max-toc-depth: 3
---------------------

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

`SchemaUtils` validates SWML documents against structural rules and provides
schema-driven verb extraction and validation. Results are cached with an
LRU-style eviction policy. Set `SWML_SKIP_SCHEMA_VALIDATION=true` to disable
validation globally.

```typescript {3}
import { SchemaUtils } from '@signalwire/sdk';

const schema = new SchemaUtils();
const result = schema.validate(swmlDocument);
console.log(result.valid, result.errors);
```

## **Constructor**

<ParamField path="opts" type="object" toc={true}>
  Optional constructor configuration.
</ParamField>

<Indent>
  <ParamField path="opts.skipValidation" type="boolean" toc={true}>
    Skip all validation checks. When omitted, defaults to `true` if the
    `SWML_SKIP_SCHEMA_VALIDATION` environment variable is `"true"`, otherwise `false`.
  </ParamField>

  <ParamField path="opts.maxCacheSize" type="number" default="100" toc={true}>
    Maximum number of cached validation results before LRU eviction.
  </ParamField>
</Indent>

## **Methods**

<CardGroup cols={3}>
  <Card title="getVerbNames" href="/docs/server-sdks/reference/typescript/agents/configuration/schema-utils/get-verb-names">
    Get all verb names defined in the SWML schema.
  </Card>

  <Card title="getVerbProperties" href="/docs/server-sdks/reference/typescript/agents/configuration/schema-utils/get-verb-properties">
    Get the inner properties schema for a specific verb.
  </Card>

  <Card title="getVerbRequiredProperties" href="/docs/server-sdks/reference/typescript/agents/configuration/schema-utils/get-verb-required-properties">
    Get the required properties for a verb.
  </Card>

  <Card title="getVerbDescription" href="/docs/server-sdks/reference/typescript/agents/configuration/schema-utils/get-verb-description">
    Get the description text for a verb.
  </Card>

  <Card title="hasVerb" href="/docs/server-sdks/reference/typescript/agents/configuration/schema-utils/has-verb">
    Check if a verb name exists in the schema.
  </Card>

  <Card title="validateVerb" href="/docs/server-sdks/reference/typescript/agents/configuration/schema-utils/validate-verb">
    Lightweight validation of a verb config against the schema.
  </Card>

  <Card title="validate" href="/docs/server-sdks/reference/typescript/agents/configuration/schema-utils/validate">
    Validate a SWML document against structural rules.
  </Card>

  <Card title="clearCache" href="/docs/server-sdks/reference/typescript/agents/configuration/schema-utils/clear-cache">
    Clear the validation result cache.
  </Card>

  <Card title="getCacheSize" href="/docs/server-sdks/reference/typescript/agents/configuration/schema-utils/get-cache-size">
    Get the number of cached validation results.
  </Card>
</CardGroup>

## **Example**

```typescript {3,5-9}
import { SchemaUtils } from '@signalwire/sdk';

const schema = new SchemaUtils();

// Validate a SWML document
const result = schema.validate({
  version: '1.0.0',
  sections: { main: [{ answer: {} }, { hangup: {} }] },
});
console.log(result.valid);  // true
console.log(result.errors); // []
```