Data Shape
To allow dependency-free definition of schemas, you can provide a "schema-shaped" object to anything
that accepts a Schema input - the SchemaResolver compilation and resolution methods, schema bases, etc.
Everything is optional; an empty shape yields an empty Schema!
A TypeScript definition of the shape would look something like:
type HandlerKeys = 'normalizers' | 'transformers' | 'finalizers' | 'validators' | 'serializers' | 'condition' | 'unionDiscriminator'
type SchemaData = {
base?: string | undefined;
properties?: Record<string|number, SchemaData> | undefined;
handlers?: Record<HandlerKeys, any[]> | undefined;
metadata?: {[key: string]: string} | undefined;
options?: {[key: string]: any} | undefined;
unionSchemas?: {[key: string]: SchemaData} | undefined;
};
You might think "hey, this is a schema library, should be able to define the schema shape using a schema", you'd
be absolutely correct - in fact, the entire
compilation process is actually implemented as a schema transform from this shape to a CompiledSchema!