Class RangeValidator<Z extends java.lang.Comparable<? super Z> & java.io.Serializable>

  • Type Parameters:
    Z - type of validatable
    All Implemented Interfaces:
    java.io.Serializable, IComponentAwareEventSink, IComponentAwareHeaderContributor, org.apache.wicket.util.io.IClusterable, IValidator<Z>
    Direct Known Subclasses:
    DateValidator

    public class RangeValidator<Z extends java.lang.Comparable<? super Z> & java.io.Serializable>
    extends AbstractRangeValidator<Z,​Z>
    Validator for checking if a given value falls within [min,max] range. If either min or max are null they are not checked.

    Resource keys:

    • RangeValidator.exact if min==max
    • RangeValidator.range if both min and max are not null
    • RangeValidator.minimum if max is null
    • RangeValidator.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:
    Serialized Form
    • Constructor Detail

      • RangeValidator

        public RangeValidator​(Z minimum,
                              Z maximum)
        Constructor that sets the minimum and maximum values.
        Parameters:
        minimum - the minimum value
        maximum - the maximum value
    • Method Detail

      • range

        public static <T extends java.lang.Comparable<? super T> & java.io.Serializable> RangeValidator<T> range​(T minimum,
                                                                                                                 T maximum)
        Parameters:
        minimum -
        maximum -
        Returns:
        a RangeValidator that validates if a value falls within a range
      • minimum

        public static <T extends java.lang.Comparable<? super T> & java.io.Serializable> RangeValidator<T> minimum​(T minimum)
        Parameters:
        minimum -
        Returns:
        a RangeValidator that validates if a value is a least minimum
      • maximum

        public static <T extends java.lang.Comparable<? super T> & java.io.Serializable> RangeValidator<T> maximum​(T maximum)
        Parameters:
        maximum -
        Returns:
        a RangeValidator that validates if a value is a most maximum
      • getValue

        protected Z getValue​(IValidatable<Z> validatable)
        Description copied from class: AbstractRangeValidator
        Gets the value that should be validated against the range
        Specified by:
        getValue in class AbstractRangeValidator<Z extends java.lang.Comparable<? super Z> & java.io.Serializable,​Z extends java.lang.Comparable<? super Z> & java.io.Serializable>
        Returns:
        value to validate