title: How to validate a model's date attribute against a specific range (evaluated at run time)
body: <p>I have several models with a date attribute and for each model I'd like to validate these dates against a given range.  A basic example would be:</p>
  
  <pre><code>validates_inclusion_of  :dated_on, :in =&gt; Date.new(2000,1,1)..Date(2020,1,1)
  </code></pre>
  
  <p>Ideally I'd like to evaluate the date range at runtime, using a similar approach as <code>named_scope</code> uses, e.g:</p>
  
  <pre><code>validates_inclusion_of  :dated_on, :in =&gt; lambda {{ (Date.today - 2.years)..(Date.today + 2.years)}}
  </code></pre>
  
  <p>The above doesn't work of course, so what is the best way of achieving the same result?  </p>