protected void onValidate(IValidatable validatable) { Date value = (Date)validatable.getValue(); if (value.before(minimum)) { error(validatable); } }
/** * Gets a <code>Date</code> minimum validator for checking if a <code>Date</code> value is * greater than the given minimum <code>Date</code> value. If that is not the case, an error * message will be generated with the key "DateValidator.minimum". The message keys that can be * used are: * <p> * <ul> * <li>${minimum}: the minimum date</li> * <li>${input}: the input the user gave</li> * <li>${name}: the name of the <code>Component</code> that failed</li> * <li>${label}: the label of the <code>Component</code> - either comes from * <code>FormComponent.labelModel</code> or resource key [form-id].[form-component-id] in that * order</li> * </ul> * * @param minimum * the minimum <code>Date</code> * * @return the requested <code>DateValidator</code> */ public static DateValidator minimum(Date minimum) { return new MinimumValidator(minimum); }
/** * Gets a <code>Date</code> minimum validator for checking if a <code>Date</code> value is * greater than the given minimum <code>Date</code> value. If that is not the case, an error * message will be generated with the key "DateValidator.minimum". The message keys that can be * used are: * <p> * <ul> * <li>${minimum}: the minimum date</li> * <li>${input}: the input the user gave</li> * <li>${name}: the name of the <code>Component</code> that failed</li> * <li>${label}: the label of the <code>Component</code> - either comes from * <code>FormComponent.labelModel</code> or resource key [form-id].[form-component-id] in that * order</li> * </ul> * * @param minimum * the minimum <code>Date</code> * * @return the requested <code>DateValidator</code> */ public static DateValidator minimum(Date minimum) { return new MinimumValidator(minimum, null); }
/** * @see #minimum(Date) * * @param minimum * the minimum <code>Date</code> * @param format * The format string used to format the date with SimpleDateFormat * * @return the requested <code>DateValidator</code> */ public static DateValidator minimum(Date minimum, String format) { return new MinimumValidator(minimum, format); }
@Override protected void onValidate(IValidatable<Date> validatable) { Date value = validatable.getValue(); if (value.before(minimum)) { error(validatable); } } }