AbstractStaticStringCreate a string field.
Create a string field descriptor.
String field configuration
Field descriptor for string values
StaticNumberCreate a number field (floating point).
Create a number field descriptor.
Number field configuration
Field descriptor for number values
StaticIntegerCreate an integer field (whole numbers only).
Create an integer field descriptor. Integers are whole numbers (no decimal places).
Integer field configuration
Field descriptor for integer values
StaticBooleanCreate a boolean field.
Create a boolean field descriptor.
Boolean field configuration
Field descriptor for boolean values
StaticNullCreate a null field.
Create a null field descriptor. Represents a field that can only be null.
Field configuration
Field descriptor for null values
StaticArrayCreate an array field with typed items.
Create an array field descriptor.
Field descriptor for array items
Array field configuration
Field descriptor for array values
StaticObjectCreate a nested object field from another Schema class.
Create an object field descriptor for nested schemas.
The nested Schema class constructor
Object field configuration
Field descriptor for nested object values
StaticEnumCreate an enum field with specific allowed values.
Use as const for literal type inference.
Create an enum field descriptor. The value must be one of the specified allowed values.
Array of allowed values (use as const for literal types)
Enum field configuration
Field descriptor for enum values
StaticLiteralCreate a literal (const) field with an exact value.
Create a literal field descriptor. The value must be exactly the specified constant.
The exact value this field must have
Literal field configuration
Field descriptor for literal values
StaticcreateCreate a new proxied schema instance.
The Schema class to instantiate
A proxied instance with clean property access
StaticparseValidate and populate a schema instance with data. Throws SchemaError if validation fails.
StaticvalidateValidate data against a schema without modifying the instance.
true if valid, false otherwise
StatictoGenerate a JSON Schema document from a schema instance.
JSON Schema object conforming to draft 2020-12
StaticstringifyGenerate a JSON Schema string from a schema instance.
JSON Schema as a string
StatictoExtract a plain JavaScript object from a schema instance.
Plain object with field values
Staticclone
Abstract base class for defining type-safe schemas.
Extend this class and define fields using the static type methods. Use static functions to create, parse, validate, and serialize instances.
Example