* @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));
}