title: Node.js - Joi schema: Check req.value & ip not working
body: <p>I have this joi schema to validate email and password that was sent via body as json. In addition I now want to check the ip address. I tried it like below but I get this:</p>
  
  <pre><code>{
      "isJoi": true,
      "name": "ValidationError",
      "details": [
          {
              "message": "\"ip\" is required",
              "path": [
                  "ip"
              ],
              "type": "any.required",
              "context": {
                  "key": "ip",
                  "label": "ip"
              }
          }
      ],
      "_object": {
          "email": "loremlipsum02@abc.at",
          "password": "kyuser2923?"
      }
  }
  </code></pre>
  
  <p>Here my joi schema in routehelpers.js</p>
  
  <pre><code>const Joi = require('joi');
  
  module.exports = {
      validateSignup: (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: {
          signupSchema: Joi.object().keys({
              email: Joi.string().email().required(),
              password: Joi.string().required(),
              ip: Joi.string().ip({
                version: [
                  'ipv4',
                  'ipv6'
                ],
                cidr: 'required'
              }).required()
          })
      }
  }
  </code></pre>
  
  <p>When I insert in my controller: </p>
  
  <pre><code>const curIP = req.ip;
  console.log('IP: '+curIP);
  </code></pre>
  
  <p>I do get the ip in the console:</p>
  
  <pre><code>Server running at http://127.0.0.1:4002/
  IP: 127.0.0.1
  </code></pre>
  
  <p>But how in addition can I validate the ip from the server requesting a signup?  </p>
  
  <p>I suppose it is because it is checking everything in req.value.body . But how do I need to alter validateSignup: (schema) to also check the ip that is requesting signup?</p>