Skip to Content
@jetio/schema-builder docs are live 🎉
API ReferenceType Definitions

Type Definitions

// Core types type BuilderSchema = SchemaDefinition | SchemaBuilder<any> | boolean; // $data reference for dynamic values type $data = { $data: string }; // Schema callback pattern type SchemaCallback = (builder: SchemaBuilder) => SchemaBuilder;

Common patterns

Inline schema definition

.properties({ name: (s) => s.string(), age: (s) => s.number(), })

Reusable schema

const nameSchema = new SchemaBuilder().string().build(); // Later .properties({ name: nameSchema })

Boolean schemas

.properties({ allowAny: true, // accepts any value rejectAll: false, // rejects all values })

Composition patterns

// Using callbacks .allOf( (s) => s.object().properties({ id: (s) => s.number() }), (s) => s.object().properties({ name: (s) => s.string() }), ) // Using existing schemas const baseSchema = new SchemaBuilder().object().build(); .allOf(baseSchema, otherSchema) // Mixed .oneOf( baseSchema, (s) => s.object().properties({ type: (s) => s.const("custom") }), )
Last updated on