title: Hapijs Joi reference schema keys to reuse in other models or in routes
body: <p>I have an example model constructed like so:</p>
  
  <pre><code>const MyModelResponse = Joi.object().keys({
    id: Joi.number().integer().required()
      .description('ID of the example model'),
    description: Joi.string()
      .description('Description of the example model'),
  })
    .description('example instance of MyModel with the unique ID present')
    .label('MyModelResponse');
  </code></pre>
  
  <p>In my route, I want to make sure that my input parameter is validated against the id property of MyModeResponse like so:</p>
  
  <pre><code>     validate: {
          params: {
            id: MyModelResponse.id,
          },
          options: { presence: 'required' },
          failAction: failAction('request'),
        }
  </code></pre>
  
  <p>This results in the schema validation error upon server start:</p>
  
  <pre><code>AssertionError [ERR_ASSERTION]: Invalid schema content: (id)
  </code></pre>
  
  <p>Is there a way to reference a key of a schema? Currently, I have to resort to either of the following:</p>
  
  <p>Not referencing my MyModelResponse schema at all:</p>
  
  <pre><code>     validate: {
          params: {
            id: Joi.number().integer().description('id of MyModel instance to get'),
          },
          options: { presence: 'required' },
          failAction: failAction('request'),
        }
  </code></pre>
  
  <p>Not using the Joi.object.keys() constructor by defining my model like this:</p>
  
  <pre><code>const MyModelResponse = {
    id: Joi.number().integer().required()
      .description('ID of the example model'),
    description: Joi.string()
      .description('Description of the example model'),
  }
  </code></pre>
  
  <p>The bottom approach allows me to reference the id property in my route but doesn't allow me to add descriptions and labels to my schema. I have tried using MyModel.describe().children.id in my route validation and I have made some attempts to deserialize the id object into a schema object to no avail.</p>
  
  <p>Any suggestions would be appreciated.</p>