diff --git a/curriculum/package-lock.json b/curriculum/package-lock.json index af9de82389..8f6938a298 100644 --- a/curriculum/package-lock.json +++ b/curriculum/package-lock.json @@ -7437,12 +7437,6 @@ "spdx-expression-parse": "^3.0.0" } }, - "validator": { - "version": "10.11.0", - "resolved": "https://registry.npmjs.org/validator/-/validator-10.11.0.tgz", - "integrity": "sha512-X/p3UZerAIsbBfN/IwahhYaBbY68EN/UQBWHtsbXGT5bfrH/p4NQzUCG1kF/rtKaNpnJ7jAu6NGTdSNtyNIXMw==", - "dev": true - }, "value-or-function": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/value-or-function/-/value-or-function-3.0.0.tgz", diff --git a/curriculum/package.json b/curriculum/package.json index a6af835376..297ecd3d66 100644 --- a/curriculum/package.json +++ b/curriculum/package.json @@ -57,7 +57,6 @@ "puppeteer": "^5.3.1", "readdirp-walk": "^1.7.0", "rx": "^4.1.0", - "string-similarity": "^4.0.2", - "validator": "^10.4.0" + "string-similarity": "^4.0.2" } } diff --git a/curriculum/test/utils/mongoIds.js b/curriculum/test/utils/mongoIds.js index 2ef3c3a2f9..ee5e42d469 100644 --- a/curriculum/test/utils/mongoIds.js +++ b/curriculum/test/utils/mongoIds.js @@ -1,15 +1,21 @@ -const _ = require('lodash'); -const { isMongoId } = require('validator'); +const findIndex = require('lodash/findIndex'); +const Joi = require('joi'); +Joi.objectId = require('joi-objectid')(Joi); + +const schema = Joi.objectId(); class MongoIds { constructor() { this.knownIds = []; } check(id, title) { - if (!isMongoId(id)) { + try { + Joi.validate(id, schema); + } catch { throw new Error(`Expected a valid ObjectId for ${title}, but got ${id}`); } - const idIndex = _.findIndex(this.knownIds, existing => id === existing); + + const idIndex = findIndex(this.knownIds, existing => id === existing); if (idIndex !== -1) { throw new Error(` All challenges must have a unique id.