diff --git a/lib/helpers/isAsyncFunction.js b/lib/helpers/isAsyncFunction.js index 81846e24c4c..ecd2872af0e 100644 --- a/lib/helpers/isAsyncFunction.js +++ b/lib/helpers/isAsyncFunction.js @@ -8,4 +8,4 @@ module.exports = function isAsyncFunction(v) { } return inspect(v).startsWith('[AsyncFunction:'); -} \ No newline at end of file +}; \ No newline at end of file diff --git a/lib/schematype.js b/lib/schematype.js index 5032dc3e663..a26b1d71ec4 100644 --- a/lib/schematype.js +++ b/lib/schematype.js @@ -1270,48 +1270,6 @@ SchemaType.prototype.doValidate = function(value, fn, scope, options) { } }; -/*! - * Handle async validators - */ - -function asyncValidate(validator, scope, value, props, cb) { - let called = false; - const returnVal = validator.call(scope, value, function(ok, customMsg) { - if (called) { - return; - } - called = true; - if (customMsg) { - props.message = customMsg; - } - cb(ok, props); - }); - if (typeof returnVal === 'boolean') { - called = true; - cb(returnVal, props); - } else if (returnVal && typeof returnVal.then === 'function') { - // Promise - returnVal.then( - function(ok) { - if (called) { - return; - } - called = true; - cb(ok, props); - }, - function(error) { - if (called) { - return; - } - called = true; - - props.reason = error; - props.message = error.message; - cb(false, props); - }); - } -} - /** * Performs a validation of `value` using the validators declared for this SchemaType. * diff --git a/package.json b/package.json index 465875ef2e2..b68254dbe42 100644 --- a/package.json +++ b/package.json @@ -128,7 +128,7 @@ "mocha-no-only" ], "parserOptions": { - "ecmaVersion": 2015 + "ecmaVersion": 2020 }, "env": { "node": true, diff --git a/test/typescript/discriminator.ts b/test/typescript/discriminator.ts index 9b80adae4b9..052e3c3ba3c 100644 --- a/test/typescript/discriminator.ts +++ b/test/typescript/discriminator.ts @@ -43,25 +43,25 @@ function test(): void { const cardDbSchema: Schema = new Schema( cardDbBaseSchemaDefinition, - cardDbSchemaOptions, + cardDbSchemaOptions ); const cardDbModel: Model = mongoose.model( 'Card', cardDbSchema, - 'card', + 'card' ); const landDbAdditionalPropertiesSchemaDefinition: SchemaDefinition = {}; const landDbSchema: Schema = new Schema( - landDbAdditionalPropertiesSchemaDefinition, + landDbAdditionalPropertiesSchemaDefinition ); const landDbModel: Model = cardDbModel.discriminator( 'Land', landDbSchema, - CardType.Land, + CardType.Land ); const sampleLandDb: LandDb = new landDbModel({