Class AbstractIntervalValidator<T>

Type Parameters:
T - The type tested by the validator.
All Implemented Interfaces:
ContentValidator, Configurable, LogEnabled
Direct Known Subclasses:
AbstractNumberIntervalValidator, DateIntervalValidator, DateTimeIntervalValidator

public abstract class AbstractIntervalValidator<T> extends AbstractContentValidator implements Configurable
Base ContentValidator validating the content by comparing one or more couples of values. For each couple of values, the identified max value should be greater than or equal to the identified min value.
  • Constructor Details

  • Method Details

    • configure

      public void configure(Configuration configuration) throws ConfigurationException
      Specified by:
      configure in interface Configurable
      Throws:
      ConfigurationException
    • validate

      public void validate(Content content, Errors errors)
      Description copied from interface: ContentValidator
      Validates a content.
      Specified by:
      validate in interface ContentValidator
      Parameters:
      content - the content to validate
      errors - the structure to populate if the validation failed.
    • _validateInterval

      protected void _validateInterval(Content content, Errors errors, ElementDefinition minDefinition, ElementDefinition maxDefinition, Object minValues, Object maxValues)
      Validate the interval values of a content
      Parameters:
      content - The content
      errors - The list of errors to fill
      minDefinition - The definition for the min value
      maxDefinition - The definition for the max value
      minValues - The list of min values
      maxValues - The list of max values
    • validate

      public void validate(Content content, Map<String,Object> values, View view, Errors errors)
      Description copied from interface: ContentValidator
      Validates a content being edited
      Specified by:
      validate in interface ContentValidator
      Parameters:
      content - the content to validate
      values - the values being set
      view - the view
      errors - the structure to populate if the validation failed.
    • configureMinPath

      protected abstract String configureMinPath(Configuration configuration) throws ConfigurationException
      Get the metadata min path from the configuration
      Parameters:
      configuration - The configuration
      Returns:
      The metadata min path
      Throws:
      ConfigurationException - If an error occurs
    • configureMaxPath

      protected abstract String configureMaxPath(Configuration configuration) throws ConfigurationException
      Get the metadata max path from the configuration
      Parameters:
      configuration - The configuration
      Returns:
      The metadata max path
      Throws:
      ConfigurationException - If an error occurs
    • 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.
    • isSupportedType

      protected abstract boolean isSupportedType(ElementType type)
      Test if the attribute type is one expected by the validator
      Parameters:
      type - The attribute type
      Returns:
      True if the type is supported
    • addIntervalError

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

      protected abstract void addErrorEmpty(Errors errors, ElementDefinition minDefinition, ElementDefinition maxDefinition, I18nizableText emptyLabel)
      Add an error when the max or the min value is empty but the interval is mandatory
      Parameters:
      errors - The list of errors
      minDefinition - The min definition
      maxDefinition - The max definition
      emptyLabel - The label of the empty field