title: Validating double and float values using Hibernate Validator - bean validation
body: <p>I'm looking for a way to validate a <code>java.lang.Double</code> field in the Spring command bean for its maximum and minimum values (a value must lie between a given range of values) like,</p>
  
  <pre><code>public final class WeightBean
  {
       @Max(groups={ValidationGroup.class}, value=Double.MAX_VALUE, message="some key or default message")
       @Min(groups={ValidationGroup.class}, value=1D, message="some key or default message")
       private Double txtWeight;  //Getter and setter.
  
       public interface ValidationGroup{}         
  }
  </code></pre>
  
  <p>But both <a href="http://docs.oracle.com/javaee/6/api/javax/validation/constraints/Max.html" rel="noreferrer"><code>@Max</code></a> and <a href="http://docs.oracle.com/javaee/6/api/javax/validation/constraints/Min.html" rel="noreferrer"><code>@Min</code></a> cannot take a <code>java.lang.Double</code> value.</p>
  
  <blockquote>
    <p>Note that double and float are not supported due to rounding errors
    (some providers might provide some approximative support)</p>
  </blockquote>
  
  <p>So what is the way of validating such fields?</p>
  
  <p>I'm working with Spring 3.2.0 and Hibernate Validator 4.3.1 CR1.</p>