2026-03-31 12:17:46 +08:00
|
|
|
export type SchemaType = 'string' | 'number' | 'boolean';
|
|
|
|
|
|
|
|
|
|
export interface PrimitiveSchema {
|
|
|
|
|
type: SchemaType;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-31 16:36:32 +08:00
|
|
|
export interface NamedSchema {
|
|
|
|
|
name?: string;
|
|
|
|
|
schema: Schema;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-31 12:17:46 +08:00
|
|
|
export interface TupleSchema {
|
|
|
|
|
type: 'tuple';
|
2026-03-31 16:36:32 +08:00
|
|
|
elements: NamedSchema[];
|
2026-03-31 12:17:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ArraySchema {
|
|
|
|
|
type: 'array';
|
|
|
|
|
element: Schema;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type Schema = PrimitiveSchema | TupleSchema | ArraySchema;
|
|
|
|
|
|
|
|
|
|
export interface ParsedSchema {
|
|
|
|
|
schema: Schema;
|
|
|
|
|
validator: (value: unknown) => boolean;
|
|
|
|
|
parse: (valueString: string) => unknown;
|
|
|
|
|
}
|