title: Joi multiple when condition
body: <p>I want to do a validation with Joi in my body, but it seems never work and fall all the time in the same condition.
  So if i <strong>POST</strong> with this </p>
  
  <p>endPoint: <strong><em>/elasticSearch?eType=scroll&amp;scroll=1h</em></strong></p>
  
  <p>Body:{}</p>
  
  <p>that supposed to throw an error, because eType is <strong>scroll</strong> and in this case <strong>scroll_id</strong> need to be required,not null, not empty.</p>
  
  <p>even when i <strong>POST</strong> with this</p>
  
  <p>endPoint: <strong><em>/elasticSearch?eType=search&amp;scroll=1h</em></strong></p>
  
  <p>Body:{}</p>
  
  <p>that supposed to throw an error, because eType is <strong><em>search</em></strong> and in this case <strong><em>query</em></strong> need to be required.</p>
  
  <p>so with these codes,</p>
  
  <p>in one case it just always pass like if it's had no validation even if they should not pass in my opinion and in the second case, i got error: query is required, and scroll_id is required all the time when i make a call.</p>
  
  <p>so someone can help me to understand why these validation are wrong ? </p>
  
  <p>Thanks</p>
  
  <h2><strong><em>Update</em></strong></h2>
  
  <p>By default, if i do that like this:  </p>
  
  <pre><code>body: 
    { 
      query: 
       Joi.alternatives()
       .when(Joi.ref('$query.eType'), 
        { 
         is: Joi.string().equal('search'), 
         then: Joi.required() 
        }
       ), 
     scroll_id: 
      Joi.alternatives() 
       .when(Joi.ref('$query.eType'), 
       { 
        is: Joi.string().equal('scroll'), 
        then: Joi.required() 
       }
      ) 
     }
  </code></pre>
  
  <p>That required query and scroll_id all time.</p>