1 | import { Request, ValidationError } from './base';
|
2 | export declare type ErrorFormatter<T = any> = (error: ValidationError) => T;
|
3 | export declare type ResultFactory<T> = (req: Request) => Result<T>;
|
4 | interface ResultFactoryBuilderOptions<T = any> {
|
5 | formatter: ErrorFormatter<T>;
|
6 | }
|
7 | export declare const validationResult: ResultFactory<ValidationError> & {
|
8 | withDefaults: typeof withDefaults;
|
9 | };
|
10 | export declare class Result<T = any> {
|
11 | private formatter;
|
12 | private readonly errors;
|
13 | constructor(formatter: ErrorFormatter<T>, errors: readonly ValidationError[]);
|
14 | array(options?: {
|
15 | onlyFirstError?: boolean;
|
16 | }): T[];
|
17 | mapped(): Record<string, T>;
|
18 | formatWith<T2>(formatter: ErrorFormatter<T2>): Result<T2>;
|
19 | isEmpty(): boolean;
|
20 | throw(): void;
|
21 | }
|
22 | declare function withDefaults<T = any>(options?: Partial<ResultFactoryBuilderOptions<T>>): ResultFactory<T>;
|
23 | export {};
|