Package org.internna.iwebmvc.core.validation.annotation

Examples of org.internna.iwebmvc.core.validation.annotation.DateConstraint


     * @param field the field to be validated
     * @param object the value to be validated
     * @return a collection of {@link ValidationError}
     */
    protected Set<ValidationError> validateDateConstraint(final Field field, final Object object) {
        final DateConstraint dateConstraint = field.getAnnotation(DateConstraint.class);
        Set<ValidationError> errors = new HashSet<ValidationError>();
        if (dateConstraint != null) {
            if (dateConstraint.required() & (object == null)) errors.add(new ValidationError(field.getName(), errorCodes[0], dateConstraint, object));
            if (object != null) {
                Calendar min = dateConstraint.minValue().getDate(false);
                Calendar max = dateConstraint.maxValue().getDate(true);
                Calendar date = Calendar.getInstance();
                date.setTime((Date) object);
                if (date.before(min)) errors.add(new ValidationError(field.getName(), errorCodes[2], dateConstraint, object));
                if (date.after(max)) errors.add(new ValidationError(field.getName(), errorCodes[3], dateConstraint, object));
            }
View Full Code Here

TOP

Related Classes of org.internna.iwebmvc.core.validation.annotation.DateConstraint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.