title: Joi object validation: How to validate values with unknown key names?
body: <p>I have an object with key names I cannot possibly know - they are created by user. However I do know what values they (keys) are going to store, and they (values) are going to be ISO strings. How do I validate those values? And, <em>optionally</em>, how do I validate uknown object's keys, i.e.: </p>
  
  <pre><code> key: Joi.string().min(2).max(25)
  </code></pre>
  
  <p>What I have already tried was based on Joi API docs :</p>
  
  <blockquote>
    <p>Another benefits of using Joi.object([schema]) instead of a plain JS object is >that you can set any options on the object like <strong>allowing unknown keys</strong>, e.g:</p>
    
    <p><code>const schema = Joi.object({
       arg: Joi.string().valid('firstname', 'lastname', 'title', 'company', 'jobtitle'),
       value: Joi.string(),
    }).pattern(/firstname|lastname/, Joi.string().min(2));</code></p>
  </blockquote>
  
  <p>What I understood from the example is that <code>arg</code> key represents <code>Joi.object()</code>'s <code>key</code>, and <code>value</code> represents it's <code>value</code>. </p>
  
  <p><strong>My example:</strong></p>
  
  <pre><code>campaign: Joi.object({
    arg: Joi.string().valid( 'unknown' ),
    value: Joi.date().iso(),
  }).pattern( /unknown/, Joi.string().min(2).max(25) )
  </code></pre>
  
  <p><strong>My input;</strong></p>
  
  <pre><code>campaign: { g_ad_adwords: "2017-01-19T11:33:26.205Z" }
  </code></pre>
  
  <p><strong>My error:</strong></p>
  
  <blockquote>
    <p>"campaign" fails because ["g_ad_adwords" is not allowed]</p>
  </blockquote>