UNPKG

723 BTypeScriptView Raw
1declare 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 value: any;
8 }
9
10 interface ValidatorMessageFn {
11 (props: ValidatorProps): string;
12 }
13
14 interface ValidateFn<T> {
15 (value: T): boolean;
16 }
17
18 interface LegacyAsyncValidateFn<T> {
19 (value: T, done: (result: boolean) => void): void;
20 }
21
22 interface AsyncValidateFn<T> {
23 (value: any): Promise<boolean>;
24 }
25
26 interface ValidateOpts<T> {
27 msg?: string;
28 message?: string | ValidatorMessageFn;
29 type?: string;
30 validator: ValidateFn<T> | LegacyAsyncValidateFn<T> | AsyncValidateFn<T>;
31 }
32}