title: TypeError: Joi.validate is not a function
body: <p>I have tried all the solutions offered in this site and GitHub but it didn't work for me because my routes/user.js is structured differently. Also, I am new in Nodejs.
  I need help  to change <code>const result = Joi.validate(req.body, schema);</code>  in the routeHelper.js and</p>
  <pre><code>const {validateBody, schemas} = require('../helpers/routehelpers');  
  router.route('/signup')
  .post(validateBody(schemas.authSchema),userController.signup);
  </code></pre>
  <p>in the <code>routes/user.js</code></p>
  <pre><code> //routeHelper.js
   const Joi = require('joi');
      module.exports = {
        validateBody: (schema) =&gt; {
          return (req, res, next) =&gt; {
            const result = Joi.validate(req.body, schema);
            if (result.error) {
              return res.status(400).json(result.error);
            }
  
        if (!req.value) { req.value = {}; }
        req.value['body'] = result.value;
        next();
      }
    },
  
    schemas: {
      authSchema: Joi.object().keys({
        email: Joi.string().email().required(),
        password: Joi.string().required()
      })
    }
  }
  
  //routes/user.js
  const express = require('express'),
        router  = require('express-promise-router')();
  const userController = require('../controller/user');
  const {validateBody, schemas} = require('../helpers/routehelpers');
  const passport = require('passport')
  const passportConfig = require('../passport')
  
  router.route('/signup')
  .post(validateBody(schemas.authSchema),userController.signup);
  
  
  
  router.route('/signin')
  .post(userController.signin);
  
  router.route('/secret')
  .get(passport.authenticate('jwt',{session:false}),userController.secret);
  
  module.exports = router;
  </code></pre>