title: Enforce constraints on @Value annotated field in Spring Boot application
body: <p>I have the following field annotated with <code>@Value</code>, specifying a default value:</p>
  
  <pre><code>@Value("${tolerance.percentage:25}")
  private int tolerance;
  </code></pre>
  
  <p>That code correctly initializes the value of the field to the system property "tolerance.percentage" if that prop exists.  If it doesn't exist, it defaults to 25.</p>
  
  <p>I want to go one step further, though, by enforcing a min and max on this int field, since it represents a percentage less than 100 as a whole number, and Murphy's law means someone (probably me) can externally misconfigure the property and my app would start doing weird things at runtime, which is way too late for my liking.  I  would like an error to be thrown if the property is set to "101" or "-1" upon application startup.  Heck, I'd even like for an error to be thrown if I try to default it to 101 in the <code>@Value</code> annotation, but that's not important for the purposes of this question.  Here's what I tried:</p>
  
  <pre><code>//@Min and @Max don't produce the intended behavior when combined with @Value
  @Min(0)
  @Max(100)
  @Value("${tolerance.percentage:25}")
  private int tolerance;
  </code></pre>
  
  <p>Can I enforce a min and max on an <code>int</code> field that <code>@Value</code> is aware of?</p>