Skip to content

Commit

Permalink
Merge pull request #12606 from Freezystem/patch-1
Browse files Browse the repository at this point in the history
Improve ValidateOpts type
  • Loading branch information
vkarpov15 committed Oct 28, 2022
2 parents d684fd2 + 3df419f commit e693249
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions types/validation.d.ts
Expand Up @@ -12,21 +12,22 @@ declare module 'mongoose' {
}

interface ValidateFn<T> {
(value: T): boolean;
(value: T, props?: ValidatorProps & Record<string, any>): boolean;
}

interface LegacyAsyncValidateFn<T> {
(value: T, done: (result: boolean) => void): void;
}

interface AsyncValidateFn<T> {
(value: any): Promise<boolean>;
(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;
}
}

0 comments on commit e693249

Please sign in to comment.