Skip to content

(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

Description

@denzilgupta

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-validators

I 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

Activity

  1. added this to the 5.7.3 milestone on Sep 26, 2019
  2. added
    docsThis issue is due to a mistake or omission in the mongoosejs.com documentation
    on Sep 26, 2019
  3. modified the milestones: 5.7.3, 5.7.4 on Sep 27, 2019
  4. modified the milestones: 5.7.4, 5.7.3 on Sep 29, 2019
  5. denzilgupta commented on Nov 13, 2019

    @denzilgupta
    Author

    @LouiseEmike Can you show me the code? I think I'll be able to help you out better then.

  6. receptopalak commented on Nov 13, 2019

    @receptopalak

    @denzilgupta
    I get the same error, can you help me urgently

    const mongoose = require('mongoose');
    const Schema = mongoose.Schema;
    //const GeoJSON = require('mongoose-geojson-schema');
    const {
    Point,
    LineString,
    Polygon,
    MultiPoint,
    MultiLineString,
    MultiPolygon,
    Geometry,
    GeometryCollection
    } = require('mongoose-geojson-schemas');

    //new geo location schema
    //const Geo = new Schema(Schema.Types.Point);

    const geojson = new Schema(

    {
        konum: {
            type:  String,
            default: "Sazlıdere"
        },
        type: {
            type: String,
            default: "Feature"
        },
        properties: {
            name: {
                type: String,
                default: "bina"
            },
            surname: {
                type: String,
                default: "bina"
            }
        },
        geometry: Polygon
    }
    

    );
    const barrage = mongoose.model('intersect', geojson);
    module.exports = barrage;

  7. denzilgupta commented on Nov 13, 2019

    @denzilgupta
    Author

    @denzilgupta
    I get the same error, can you help me urgently

    const mongoose = require('mongoose');
    const Schema = mongoose.Schema;
    //const GeoJSON = require('mongoose-geojson-schema');
    const {
    Point,
    LineString,
    Polygon,
    MultiPoint,
    MultiLineString,
    MultiPolygon,
    Geometry,
    GeometryCollection
    } = require('mongoose-geojson-schemas');

    //new geo location schema
    //const Geo = new Schema(Schema.Types.Point);

    const geojson = new Schema(

    {
        konum: {
            type:  String,
            default: "Sazlıdere"
        },
        type: {
            type: String,
            default: "Feature"
        },
        properties: {
            name: {
                type: String,
                default: "bina"
            },
            surname: {
                type: String,
                default: "bina"
            }
        },
        geometry: Polygon
    }
    

    );
    const barrage = mongoose.model('intersect', geojson);
    module.exports = barrage;

    Are you getting an error on this file? Cause it seems to look fine.

  8. receptopalak commented on Nov 13, 2019

    @receptopalak

    @denzilgupta yes, ı getting an error, ı think because of mongoose-geojson-schema npm package, can you help me ?

  9. vkarpov15 commented on Nov 16, 2019

    @vkarpov15
    Collaborator

    @receptopalak please open a new issue and follow the issue template. Also, check out our geojson docs: https://mongoosejs.com/docs/geojson.html

  10. locked as resolved and limited conversation to collaborators on Nov 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsThis issue is due to a mistake or omission in the mongoosejs.com documentation

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions