<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I have gathered feedback from various places and as expected everyone has his favorite best solution.<div><br></div><div>I am on the fence to support this:</div><div> - @Max with long not supporting double and float</div><div> - @MaxDecimal with String (BigDecimal style) not supporting double and float</div><div> - same for min</div><div><br></div><div>WDTY? </div><div>Better names encouraged.</div><div><br></div><div><br></div><div><div>/**</div><div> * The annotated element must be a number whose value must be lower or</div><div> * equal than the specificed maximum.</div><div> * <p/></div><div> * Supported types are:</div><div> * <ul></div><div> * <li><code>BigDecimal</code></li></div><div> * <li><code>BigInteger</code></li></div><div> * <li><code>byte</code>, <code>short</code>, <code>int</code>, <code>long</code> </div><div> * <b>and their respective wrappers<span class="Apple-style-span" style="font-weight: normal; "></li></span></b></div><div> * </ul></div><div> * <b>Note that double and float are not supported due to rounding errors (some providers </b></div><div><b> * might provide approximative support)</b></div><div> * <p/></div><div> * <code>null</code> elements are considered valid</div><div> *</div><div> * @author Emmanuel Bernard</div><div> */</div><div>@Target({ METHOD, FIELD, ANNOTATION_TYPE })</div><div>@Retention(RUNTIME)</div><div>@Documented</div><div>public @interface Max {</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>String message() default "{validator.max}";</div><div><br></div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>Class<?>[] groups() default { };</div><div><br></div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>/**</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span> * @return Value the element must be lower or equal to</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span> */</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>long value();</div><div><br></div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>/**</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span> * Defines several @Max annotations on the same element</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span> * @see Max</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span> *</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span> * @author Emmanuel Bernard</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span> */</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>@Target({ METHOD, FIELD, ANNOTATION_TYPE })</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>@Retention(RUNTIME)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>@Documented</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>@interface List {</div><div><span class="Apple-tab-span" style="white-space: pre; ">                </span>Max[] value();</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>}</div><div>}</div><div><br></div><div><br></div><div><br></div><div><div>/**</div><div> * The annotated element must be a number whose value must be lower or</div><div> * equal than the specificed maximum.</div><div> * <p/></div><div> * Supported types are:</div><div> * <ul></div><div> * <li><code>BigDecimal</code></li></div><div> * <li><code>BigInteger</code></li></div><div> * <li><code>byte</code>, <code>short</code>, <code>int</code>, <code>long</code> </div><div> * <b>and their respective wrappers<span class="Apple-style-span" style="font-weight: normal; "></li></span></b></div><div> * </ul></div><div> * <b>Note that double and float are not supported due to rounding errors (some providers </b></div><div><b> * might provide approximative support)</b></div><div> * <p/></div><div> * <code>null</code> elements are considered valid</div><div> *</div><div> * @author Emmanuel Bernard</div><div> */</div><div>@Target({ METHOD, FIELD, ANNOTATION_TYPE })</div><div>@Retention(RUNTIME)</div><div>@Documented</div><div>public @interface MaxDecimal {</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>String message() default "{validator.max}";</div><div><br></div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>Class<?>[] groups() default { };</div><div><br></div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span><b>/**</b></div><div><b> * The string representation of the max value according to the BigDecimal representation</b></div><div><span class="Apple-tab-span" style="white-space: pre; "><b>        </b></span><b> * @return Value the element must be lower or equal to</b></div><div><span class="Apple-tab-span" style="white-space: pre; "><b>        </b></span><b> */</b></div><div><span class="Apple-tab-span" style="white-space: pre; "><b>        </b></span><b>String value();</b></div><div><br></div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>/**</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span> * Defines several @Max annotations on the same element</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span> * @see Max</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span> *</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span> * @author Emmanuel Bernard</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span> */</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>@Target({ METHOD, FIELD, ANNOTATION_TYPE })</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>@Retention(RUNTIME)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>@Documented</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>@interface List {</div><div><span class="Apple-tab-span" style="white-space: pre; ">                </span>Max[] value();</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>}</div><div>}</div></div></div></div></div></body></html>