title: Validate referential integrity of object arrays with Joi
body: <p>I'm trying to validate that the data I am returned it sensible. Validating data types is done. Now I want to validate that I've received all of the data needed to perform a task.</p>
  
  <p>Here's a representative example:</p>
  
  <pre><code>{
    "things": [
      {
        "id": "00fb60c7-520e-4228-96c7-13a1f7a82749",
        "name": "Thing 1",
        "url": "https://lolagons.com"
      },
      {
        "id": "709b85a3-98be-4c02-85a5-e3f007ce4bbf",
        "name": "Thing 2",
        "url": "https://lolfacts.com"
      }
    ],
    "layouts": {
      "sections": [
         {
            "id": "34f10988-bb3d-4c38-86ce-ed819cb6daee",
            "name": "Section 1",
            "content:" [
               {
                 "type": 2,
                 "id": "00fb60c7-520e-4228-96c7-13a1f7a82749" //Ref to Thing 1
               }
            ]
         }
       ]
    }
  }
  </code></pre>
  
  <p>So every Section references 0+ Things, and I want to validate that every <code>id</code> value returned in the Content of Sections also exists as an <code>id</code> in Things.</p>
  
  <p>The docs for <a href="https://github.com/hapijs/joi/blob/v10.6.0/API.md#objectassertref-schema-message" rel="nofollow noreferrer">Object.assert(..)</a> implies that I need a concrete reference. Even if I do the validation within the Object.keys or Array.items, I can't resolve the reference at the other end.</p>
  
  <p>Not that it matters, but my context is that I'm validating HTTP responses within <a href="https://github.com/MarkHerhold/IcedFrisby" rel="nofollow noreferrer">IcedFrisby</a>, a Frisby.js fork.</p>