High Performance Runtime Validation
⚠️ Notice: The
typebox/compilesubmodule is being phased out in 1.x in favor of the more versatiletypebox/schemacompiler. Whiletypebox/compilewill be maintained throughout the 1.x release cycle, future development will focus on enhancing theschemasubmodule with advanced code generation and custom emit capabilities. Users are encouraged to migrate totypebox/schemaand provide feedback regarding feature parity or functional requirements.
The Compile submodule is a high-performance, JSON Schema compliant JIT compiler that transforms schematics into efficient runtime validators. It is optimized for fast, dynamic schema compilation and delivers extremely high data-validation throughput.
import { Compile } from 'typebox/compile'
The following uses the compiler to Compile and Parse a value.
const C = Compile(Type.Object({ // const C: Validator<{}, TObject<{
x: Type.Number(), // x: TNumber,
y: Type.Number(), // y: TNumber,
z: Type.Number() // z: TNumber
})) // }>>
const A = C.Parse({ // const A: {
x: 0, // x: number,
y: 1, // y: number,
z: 0 // z: number
}) // } = ...