Class AbstractRangeValidator<R extends Comparable<? super R> & Serializable,V extends Serializable>

java.lang.Object
org.apache.wicket.behavior.Behavior
org.apache.wicket.validation.validator.AbstractRangeValidator<R,V>
Type Parameters:
R - type of range value
V - type of validatable
All Implemented Interfaces:
Serializable, IComponentAwareEventSink, IComponentAwareHeaderContributor, IClusterable, IValidator<V>
Direct Known Subclasses:
RangeValidator, StringValidator

public abstract class AbstractRangeValidator<R extends Comparable<? super R> & Serializable,V extends Serializable> extends Behavior implements IValidator<V>
Base class for validators that check if a given value falls within [min,max] range. If either min or max are null they are not checked.

Resource keys:

  • <class.simpleName>.exact if min==max
  • <class.simpleName>.range if both min and max are not null
  • <class.simpleName>.minimum if max is null
  • <class.simpleName>.maximum if min is null

Error Message Variables:

  • name: the id of Component that failed
  • label: the label of the Component (either comes from FormComponent.labelModel or resource key <form-id>.<form-component-id>
  • input: the input value
  • minimum: the minimum allowed value
  • maximum: the maximum allowed value

Author:
igor
See Also:
  • Constructor Details

  • Method Details

    • setRange

      protected final void setRange(R minimum, R maximum)
      Sets validator range
      Parameters:
      minimum -
      maximum -
    • validate

      public void validate(IValidatable<V> validatable)
      Description copied from interface: IValidator
      Validates the IValidatable instance. Validation errors should be reported using the IValidatable.error(IValidationError) method.
      Specified by:
      validate in interface IValidator<R extends Comparable<? super R> & Serializable>
      Parameters:
      validatable - the IValidatable instance being validated
    • getValue

      protected abstract R getValue(IValidatable<V> validatable)
      Gets the value that should be validated against the range
      Parameters:
      validatable -
      Returns:
      value to validate
    • getMinimum

      public R getMinimum()
      Gets the minimum value.
      Returns:
      minimum value
    • getMaximum

      public R getMaximum()
      Gets the maximum value.
      Returns:
      maximum value
    • decorate

      protected IValidationError decorate(IValidationError error, IValidatable<V> validatable)
      Allows subclasses to decorate reported errors
      Parameters:
      error -
      validatable -
      Returns:
      decorated error
    • getMode

      Gets validation mode which is determined by whether min, max, or both values are provided
      Returns:
      validation mode