From 3f0fb626b6740b21cda144ad196b417018ff359b Mon Sep 17 00:00:00 2001 From: Nico Date: Thu, 27 Oct 2022 20:06:15 +0200 Subject: [PATCH 1/2] Add missing propsParameter property to ValidateOpts type As the documention mentions [it](https://mongoosejs.com/docs/api.html#schematype_SchemaType-validate), the `propsParameter` property does not exists on the `ValidateOpts` type and cause TypeScript to generate an error. --- types/validation.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/validation.d.ts b/types/validation.d.ts index 3e6d0671a64..17ee7026090 100644 --- a/types/validation.d.ts +++ b/types/validation.d.ts @@ -28,5 +28,6 @@ declare module 'mongoose' { message?: string | ValidatorMessageFn; type?: string; validator: ValidateFn | LegacyAsyncValidateFn | AsyncValidateFn; + propsParameter?: boolean; } } From 3df419fdb49e1abbe61a13a402faa2ba0db02479 Mon Sep 17 00:00:00 2001 From: Nicolas Polizzo Date: Thu, 27 Oct 2022 20:47:24 +0200 Subject: [PATCH 2/2] Add missing optional props parameter in ValidateFn --- types/validation.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/validation.d.ts b/types/validation.d.ts index 17ee7026090..7d8924c5880 100644 --- a/types/validation.d.ts +++ b/types/validation.d.ts @@ -12,7 +12,7 @@ declare module 'mongoose' { } interface ValidateFn { - (value: T): boolean; + (value: T, props?: ValidatorProps & Record): boolean; } interface LegacyAsyncValidateFn { @@ -20,7 +20,7 @@ declare module 'mongoose' { } interface AsyncValidateFn { - (value: any): Promise; + (value: T, props?: ValidatorProps & Record): Promise; } interface ValidateOpts {