How do i fix the code below?

TypeError: Joi.validate is not a function

const Joi = require(“joi”);

module.exports = schema => (req, res, next) => {

const result = Joi.validate(req.body, schema);

if (result.error)

return res.status(400).send({ error: result.error.details[0].message });

next();

};

You’ll probably need to use schema.validate instead of Joi.validate as explained here.