24 lines
464 B
TypeScript
24 lines
464 B
TypeScript
|
|
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;
|
||
|
|
}
|