protected void onValidate(IValidatable validatable) { Date value = (Date)validatable.getValue(); if (value.after(maximum)) { error(validatable); } }
/** * Gets a <code>Date</code> maximum validator for checking if a <code>Date</code> value is * smaller than the given maximum value. If that is not the case, an error message will be * generated with the key "DateValidator.maximum". The message keys that can be used are: * <p> * <ul> * <li>${maximum}: the maximum 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 maximum * the maximum <code>Date</code> * * @return the requested <code>DateValidator</code> */ public static DateValidator maximum(Date maximum) { return new MaximumValidator(maximum, null); }
/** * Gets a <code>Date</code> maximum validator for checking if a <code>Date</code> value is * smaller than the given maximum value. If that is not the case, an error message will be * generated with the key "DateValidator.maximum". The message keys that can be used are: * <p> * <ul> * <li>${maximum}: the maximum 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 maximum * the maximum <code>Date</code> * * @return the requested <code>DateValidator</code> */ public static DateValidator maximum(Date maximum) { return new MaximumValidator(maximum); }
/** * @see #maximum(Date) * * @param maximum * the maximum <code>Date</code> * @param format * The format string used to format the date with SimpleDateFormat * * @return the requested <code>DateValidator</code> */ public static DateValidator maximum(Date maximum, String format) { return new MaximumValidator(maximum, format); }
@Override protected void onValidate(IValidatable<Date> validatable) { Date value = validatable.getValue(); if (value.after(maximum)) { error(validatable); } } }