title: Using Spring @Value inside @Size
body: <p>I am using Spring Boot and javax validation, particularly @Size.
  I am trying to grab the values for size constraints from the application.properties file:</p>
  
  <pre><code>@Size(min= @Value("${device.name.minsize}"), max=@Value("${device.name.maxsize}"))
  private String name;
  </code></pre>
  
  <p>But I receive the following compile time error:</p>
  
  <blockquote>
    <p>Error:(26, 16) java: annotation not valid for an element of type int</p>
  </blockquote>
  
  <p>Trying to fix this issue I'm attempting the following:</p>
  
  <pre><code>@Size(min=Integer.parseInt( @Value("${device.name.minsize}") ), max=Integer.parseInt( @Value("${device.name.maxsize}") ) )
  </code></pre>
  
  <p>But this has multiple errors as well.</p>
  
  <p>How can I convert the @Value annotations correctly?
  Am I headed down the wrong path?
  What I am looking for is a clean way to pull size limitations out of code and into configuration that I can access server side and in my templated angularJS/html.</p>