-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
types: correct this
for validate.validator
schematype option
#14720
Conversation
For context: I'm upgrading from Mongoose v8.2.2 to v8.6.3 When performing a document create/update, However, I believe due to these type changes make in this PR, Typescript seems to believe that Do you have any idea on how I can type the validator function so that Typescript knows that EDIT: After some experimentation, I managed to get the following somewhat working solution by specifying the type of
|
@pharapeti you're right that the workaround is to explicitly set the type of |
@vkarpov15 Thanks for confirming that, will implement the workaround for now 👍 Cheers for the speedy reply 🙏 |
Fix #14696
Summary
Ensure
this
has the correct type invalidate.validator
below.I made 2 changes to support this:
EnforcedDocType
down toValidateFn
viaValidateOpts
andSchemaValidator
LegacyAsyncValidateFn
. For some reason,LegacyAsyncValidateFn
breaks these tests, and I have no idea why. It has something to do with thedone
function. Either way,LegacyAsyncValidateFn
is no longer necessary because we removed support for validators that receive a callback in Mongoose 6, so I think it is safe to remove.Examples