altheia-async-data-validator
Version:
A very simple, fast and customizable async data validator
34 lines (33 loc) • 906 B
TypeScript
export declare type TestFunctionReturn = boolean | ValidatorInternalTestResult;
export declare type TestFunction = (params: any) => Promise<TestFunctionReturn> | TestFunctionReturn;
export interface ValidatorTestResult {
valid: boolean;
type: string;
func: TestFunction;
args: any;
result?: ValidatorInternalTestResult;
}
export interface ValidatorErrorRaw {
test: ValidatorTestResult;
label: string;
position?: number;
}
export interface ValidatorErrorFormatted {
label: string;
type: string;
message: string;
position?: number;
errors?: ValidatorErrorFormatted[];
}
export interface ValidatorInternalTest {
type: string;
func: TestFunction;
args: any;
}
export interface ValidatorInternalTestResult {
valid: boolean;
error: string;
overrideWith?: ValidatorTestResult;
errors?: ValidatorErrorRaw[];
[key: string]: any;
}