(node:25375) DeprecationWarning: Mongoose: the isAsync
option for custom validators is deprecated. Make your async va lidators return a promise instead: https://mongoosejs.com/docs/validation.html#async-custom-validators
#8184
Labels
docs
This issue is due to a mistake or omission in the mongoosejs.com documentation
Milestone
This is my code:
tags: {
type: Array,
validate: {
isAsync: true,
validator: function(value, callback) {
setTimeout(() => {
const result = value && value.minlength > 0;
callback(result);
}, 4000);
},
message: 'A course must have at least one tag'
}
}
when I try to insert a value into mongodb, I get the below warning:
(node:25375) DeprecationWarning: Mongoose: the
isAsync
option for custom validators is deprecated. Make your async va lidators return a promise instead: https://mongoosejs.com/docs/validation.html#async-custom-validatorsI saw the documentation and they too have used a callback function.
Please help me solve this problem!
Node Version:
v10.16.3
MongoDB Shell Version:
v4.2.0
Mongoose Version:
v5.7.1
The text was updated successfully, but these errors were encountered: