validata
Version:
Type safe data validation and sanitization
15 lines (14 loc) • 647 B
TypeScript
import { Path, ValueProcessor, ValueResult } from './types';
export interface TestIssue {
path?: Path[];
reason: string;
}
export interface TestDefinition<T> {
input: unknown;
expect?: T;
issues?: TestIssue[];
}
export declare const runTests: <T>(fut: ValueProcessor<T>, ...tests: TestDefinition<T>[]) => void;
export declare const expectIssue: <T>(fut: ValueProcessor<T>, value: unknown, reason: string, path?: Path[]) => void;
export declare const expectSuccess: <T>(fut: ValueProcessor<T>, value: unknown) => ValueResult<T>;
export declare const expectValue: <T>(fut: ValueProcessor<T>, value: unknown, coerced: T) => void;