inline-schema/src/types.ts

29 lines
556 B
TypeScript

export type SchemaType = 'string' | 'number' | 'int' | 'float' | 'boolean';
export interface PrimitiveSchema {
type: SchemaType;
}
export interface NamedSchema {
name?: string;
schema: Schema;
}
export interface TupleSchema {
type: 'tuple';
elements: NamedSchema[];
}
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;
}