title: Changing validation range programmatically (MVC3 ASP.NET)
body: <p>Let's say I have this view model:</p>
  
  <pre>
  
      public class MyModel
      {
          [Range(0, 999, ErrorMessage = "Invalid quantity")]
          public int Quantity { get; set; }
      }
  
  </pre>
  
  <p>Now, for specific instances of this model the range of valid values will change: some may not be 0, some may not be higher than 5. The min/max values for the valid ranges are coming from the DB and can change anytime.</p>
  
  <p>How do I change the min/max properties of the RangeAttribute on the fly? Or what it the best way to validate my scenario?</p>