express-cargo
Version:
express middleware for class-based request parsing
34 lines • 1.61 kB
TypeScript
export type Source = 'body' | 'query' | 'params' | 'header' | 'session';
type ClassConstructor = new () => any;
export type validArrayElementType = typeof String | typeof Number | typeof Boolean | typeof Date | ClassConstructor;
export type ArrayElementType = validArrayElementType | 'string' | 'number' | 'boolean' | 'date';
export type UuidVersion = 'v1' | 'v3' | 'v4' | 'v5' | 'all';
type ValidatorFunction = (value: any, instance?: Record<string | symbol, any>) => boolean;
type errorMessageFunction = (property: string | symbol, value: any) => string;
export type cargoErrorMessage = string | errorMessageFunction;
export declare class ValidatorRule {
type: string;
propertyKey: string | symbol;
validateFunction: ValidatorFunction;
message: cargoErrorMessage;
constructor(propertyKey: string | symbol, type: string, validate: ValidatorFunction, message: cargoErrorMessage);
validate(value: any, instance?: Record<string | symbol, any>): CargoFieldError | null;
}
export declare class CargoFieldError extends Error {
name: string;
field: string | symbol;
constructor(field: string | symbol, message: string);
}
export declare class CargoValidationError extends Error {
name: string;
errors: CargoFieldError[];
constructor(errors: CargoFieldError[]);
}
export declare class CargoTransformFieldError extends CargoFieldError {
constructor(field: string | symbol, message: string);
}
export type TypedPropertyDecorator<T> = <K extends string | symbol>(target: {
[P in K]?: T;
}, propertyKey: K) => void;
export {};
//# sourceMappingURL=types.d.ts.map