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



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

Hi Benbella,

We’re you able to fix the Joi validation code? If so, could you share you code. Mine is still not working. Pls, share your validation.js and listings.js files code. I’ll like to see if there’s something I’m doing wrong.