Documentation
Examples
Tutorials
JAR files
Leaks
Errata
/validator/MaxValidator.java
/validator/MaxValidator.java
package shared; import org.hibernate.mapping.Property; import org.hibernate.validator.PropertyConstraint; import org.hibernate.validator.Validator; public class MaxValidator implements Validator
, PropertyConstraint { double max; //part of the Validator
contract, //allows to get and use the annotation values public void initialize(Max parameters) { max = parameters.value(); } //part of the property constraint contract public boolean isValid(Object value) { if (value==null) return true; if ( value instanceof Number) { double valueRead = ((Number) value).doubleValue(); return valueRead <= max; } return false; } public void apply(Property arg0) { } }
Contact the author