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);