Class AbstractIntervalFormValidator<T>

java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.ametys.runtime.parameter.DefaultValidator
org.ametys.plugins.forms.question.validators.AbstractIntervalFormValidator<T>
Type Parameters:
T - the generic type to compare
All Implemented Interfaces:
Validator, PluginAware, Configurable, LogEnabled, Serviceable
Direct Known Subclasses:
DateTimeIntervalFormValidator, LocalDateIntervalFormValidator, NumberIntervalFormValidator

public abstract class AbstractIntervalFormValidator<T> extends DefaultValidator
An interval validator for generic type
  • Field Details

    • _min

      protected T _min
      The min value
    • _max

      protected T _max
      The max value
  • Constructor Details

    • AbstractIntervalFormValidator

      public AbstractIntervalFormValidator(String regexp, boolean mandatory, T min, T max)
      The constructor
      Parameters:
      regexp - the regexp
      mandatory - mandatory
      min - the min value
      max - the max value
  • Method Details

    • validateSingleValue

      protected void validateSingleValue(Object value, Errors errors)
      Description copied from class: DefaultValidator
      Validates a single value.
      Overrides:
      validateSingleValue in class DefaultValidator
      Parameters:
      value - the value to validate (can be null).
      errors - the structure to populate if the validation failed.
    • validateArrayValues

      protected void validateArrayValues(Object[] values, Errors errors)
      Description copied from class: DefaultValidator
      Validates a array of values.
      Overrides:
      validateArrayValues in class DefaultValidator
      Parameters:
      values - the values to validate
      errors - the structure to populate if the validation failed.
    • isLessThan

      protected abstract boolean isLessThan(T n1, T n2)
      Test if the first number is less than the second one.
      Parameters:
      n1 - The first number to compare.
      n2 - The second number to compare.
      Returns:
      true if the first number is less than the first, false otherwise.
    • isMoreThan

      protected abstract boolean isMoreThan(T n1, T n2)
      Test if the first number is more than the second one.
      Parameters:
      n1 - The first number to compare.
      n2 - The second number to compare.
      Returns:
      true if the first number is more than the first, false otherwise.
    • addIntervalError

      protected abstract void addIntervalError(Errors errors, T min, T max)
      Add an error when the max value is less than the min value
      Parameters:
      errors - The list of errors
      min - The min value
      max - The max value