/** * Gets a Double range validator for checking if a number falls between (including) the minimum * and maximum values. If that is not the case, an error message will be generated with the key * "RangeValidator". The message keys that can be used are: * <p> * <ul> * <li>${minimum}: the minimum value</li> * <li>${maximum}: the maximum value</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 value * @param maximum * the maximum value * * @return the requested <code>NumberValidator</code> * @deprecated see {@link org.apache.wicket.validation.validator.RangeValidator} */ @Deprecated public static NumberValidator range(double minimum, double maximum) { return new DoubleRangeValidator(minimum, maximum); }
/** * @see AbstractValidator#onValidate(IValidatable) */ protected void onValidate(IValidatable validatable) { Number value = (Number)validatable.getValue(); if (value.doubleValue() < minimum || value.doubleValue() > maximum) { error(validatable); } }
/** * Gets a Double range validator for checking if a number falls between (including) the minimum * and maximum values. If that is not the case, an error message will be generated with the key * "NumberValidator.range". The message keys that can be used are: * <p> * <ul> * <li>${minimum}: the minimum value</li> * <li>${maximum}: the maximum value</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 value * @param maximum * the maximum value * * @return the requested <code>NumberValidator</code> */ public static NumberValidator range(double minimum, double maximum) { return new DoubleRangeValidator(minimum, maximum); }
/** * @see AbstractValidator#onValidate(IValidatable) */ @Override protected void onValidate(IValidatable validatable) { Number value = (Number)validatable.getValue(); if (value.doubleValue() < minimum || value.doubleValue() > maximum) { error(validatable); } }