Function: compileSchema()
compileSchema(
schema):CompiledValidator
Defined in: src/Mnemonic/json-schema.ts:197
Pre-compiles a JsonSchema into a reusable validation function.
Inspects the schema once and builds a specialized closure that
eliminates runtime branching for unused keywords, pre-converts
required arrays to Sets, recursively pre-compiles nested property
and item schemas, and pre-builds primitive Sets for O(1) enum
lookups when possible.
Results are cached by schema object identity in a WeakMap, so
calling compileSchema with the same schema reference is free
after the first call.
Parameters
| Parameter | Type | Description |
|---|---|---|
schema | JsonSchema | The JSON Schema to compile |
Returns
A compiled validation function