joi_1.default.validate is not a function joi_1.default.validate is not a function express express

joi_1.default.validate is not a function


You fix it by changing joi.validate(request, validationSchema to validationSchema.validate(request As joi.validate() is no longer supported in v16. It is clearly documented in the API docs and release notes.


Update version of joi doesn't work with Joi.validate(req.body,schema); No need to use the object separately. Use this as following. It Worked for me smoothly. Do let me know if I am wrong at anything:

const Joi = require('@hapi/joi');const schema = Joi.object({    name:Joi.string().min(3).required(),    email:Joi.string().min(4).required().email(),    password:Joi.string().min(6).required()});router.post('/register', async (req,res) => {    //updated joi       // This is a shorter version    const { error } = schema.validate(req.body);    // Error in response    res.send(error.details[0].message);    // WORKING WITH DEPRECATED VERSION    // const Validation = Joi.validate(req.body,schema);    // res.send(Validation);


Hit the same problem when using express-joi-validation.

If it's ok for you to use version 15, downgrade Joi will make it.

npm uninstall --save @hapi/joinpm install --save @hapi/joi@15.0.3