1 | declare module 'mongoose' {
|
2 |
|
3 | type SchemaValidator<T> = RegExp | [RegExp, string] | Function | [Function, string] | ValidateOpts<T> | ValidateOpts<T>[];
|
4 |
|
5 | interface ValidatorProps {
|
6 | path: string;
|
7 | fullPath: string;
|
8 | value: any;
|
9 | }
|
10 |
|
11 | interface ValidatorMessageFn {
|
12 | (props: ValidatorProps): string;
|
13 | }
|
14 |
|
15 | interface ValidateFn<T> {
|
16 | (value: T, props?: ValidatorProps & Record<string, any>): boolean;
|
17 | }
|
18 |
|
19 | interface LegacyAsyncValidateFn<T> {
|
20 | (value: T, done: (result: boolean) => void): void;
|
21 | }
|
22 |
|
23 | interface AsyncValidateFn<T> {
|
24 | (value: T, props?: ValidatorProps & Record<string, any>): Promise<boolean>;
|
25 | }
|
26 |
|
27 | interface ValidateOpts<T> {
|
28 | msg?: string;
|
29 | message?: string | ValidatorMessageFn;
|
30 | type?: string;
|
31 | validator: ValidateFn<T> | LegacyAsyncValidateFn<T> | AsyncValidateFn<T>;
|
32 | propsParameter?: boolean;
|
33 | }
|
34 | }
|