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