inline-schema/src/types.ts

24 lines
464 B
TypeScript
Raw Normal View History

2026-03-31 12:17:46 +08:00
export type SchemaType = 'string' | 'number' | 'boolean';
export interface PrimitiveSchema {
type: SchemaType;
}
export interface TupleSchema {
type: 'tuple';
elements: Schema[];
}
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;
}