Metzploreur/node_modules/mongoose/types/validation.d.ts
clement callaert 244d45ceb8 Version 2
2023-11-01 17:33:25 +01:00

34 lines
865 B
TypeScript

declare module 'mongoose' {
type SchemaValidator<T> = RegExp | [RegExp, string] | Function | [Function, string] | ValidateOpts<T> | ValidateOpts<T>[];
interface ValidatorProps {
path: string;
fullPath: string;
value: any;
}
interface ValidatorMessageFn {
(props: ValidatorProps): string;
}
interface ValidateFn<T> {
(value: T, props?: ValidatorProps & Record<string, any>): boolean;
}
interface LegacyAsyncValidateFn<T> {
(value: T, done: (result: boolean) => void): void;
}
interface AsyncValidateFn<T> {
(value: T, props?: ValidatorProps & Record<string, any>): Promise<boolean>;
}
interface ValidateOpts<T> {
msg?: string;
message?: string | ValidatorMessageFn;
type?: string;
validator: ValidateFn<T> | LegacyAsyncValidateFn<T> | AsyncValidateFn<T>;
propsParameter?: boolean;
}
}