title: How can you base a Joi `when` condition on a value from the context?
body: <p>Joi's <a href="https://joi.dev/api/?v=17.2.1#refkey-options" rel="nofollow noreferrer">ref documentation</a> suggests that a Reference created using <code>Joi.ref</code> can refer to a value from the context object. Joi's <a href="https://joi.dev/api/?v=17.2.1#anywhencondition-options" rel="nofollow noreferrer">any.when documentation</a> suggests that the <code>condition</code> parameter accepts a Reference. However, I can't get the following simple usage to work:</p>
  <pre class="lang-js prettyprint-override"><code>import Joi from &quot;joi&quot;;
  
  const schema = Joi.object({
    year: Joi.number().when(Joi.ref(`$flag`), {
      is: Joi.boolean().truthy,
      then: Joi.number().min(2000),
    }),
  });
  
  const value = {
    year: 1999,
  };
  
  const context = {
    flag: true
  };
  
  const result = schema.validate(value, { context });
  </code></pre>
  <p>This code results in a passing validation. However, I would expect it to fail. What am I missing?</p>