@uploadx/core
Version:
Node.js resumable upload middleware
20 lines (19 loc) • 662 B
TypeScript
import { HttpError } from './errors';
import { ResponseTuple } from '../types';
export interface ValidatorConfig<T> {
value?: any;
isValid?: (t: T) => boolean | Promise<boolean>;
response?: ResponseTuple<any> | HttpError<any>;
}
export type Validation<T> = Record<string, ValidatorConfig<T>>;
export interface ValidationError extends HttpError {
name: 'ValidationError';
}
export declare function isValidationError(error: unknown): error is ValidationError;
export declare class Validator<T> {
private prefix;
private _validators;
constructor(prefix?: string);
add(config: Validation<T>): void;
verify(t: T): Promise<void>;
}