From e6fac31834b0c87bea5e7d6129973b7a647ca17d Mon Sep 17 00:00:00 2001 From: Pierre Brisorgueil Date: Fri, 6 Mar 2020 13:55:01 +0100 Subject: [PATCH] =?UTF-8?q?feat(lib):=20expose=20Joi=20function=20from=20m?= =?UTF-8?q?iddleware,=20for=20dynamic=20schema=20=E2=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/middlewares/model.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/middlewares/model.js b/lib/middlewares/model.js index c8fe33bad..57090e7f9 100644 --- a/lib/middlewares/model.js +++ b/lib/middlewares/model.js @@ -12,7 +12,7 @@ const responses = require(path.resolve('./lib/helpers/responses')); /** * get Joi result */ -const getResultFromJoi = (body, schema, options) => Joi.validate(body, schema, options, (err, data) => { +module.exports.getResultFromJoi = (body, schema, options) => Joi.validate(body, schema, options, (err, data) => { if (err) { const output = { status: 'failed', @@ -41,7 +41,7 @@ module.exports.isValid = (schema) => (req, res, next) => { options.noDefaults = true; } // Validate req.body using the schema and validation options - const result = getResultFromJoi(req.body, schema, options); + const result = this.getResultFromJoi(req.body, schema, options); // if error if (result && result.error) { if (result.error.original && (result.error.original.password || result.error.original.firstname)) result.error.original = _.pick(result.error.original, config.whitelists.users.default);