Class DoubleMaxValidator<T>

java.lang.Object
io.jmix.ui.component.validation.AbstractValidator<T>
io.jmix.ui.component.validation.DoubleMaxValidator<T>
Type Parameters:
T - Double and String that represents Double value with current locale
All Implemented Interfaces:
Validator<T>, Consumer<T>

@Component("ui_DoubleMaxValidator") @Scope("prototype") public class DoubleMaxValidator<T> extends AbstractValidator<T>
DoubleMax validator checks that value must be greater than or equal to the specified maximum.

For error message it uses template string and it is possible to use '${value}' and '${max}' keys for formatted output.

In order to provide your own implementation globally, create a subclass and register it in configuration class, for example:

     @Bean("ui_DoubleMaxValidator")
     @Scope(BeanDefinition.SCOPE_PROTOTYPE)
     @Primary
     protected DoubleMaxValidator doubleMaxValidator(Double max) {
          return new CustomDoubleMaxValidator(max);
     }
 
  • Field Details

    • max

      protected Double max
    • inclusive

      protected boolean inclusive
  • Constructor Details

    • DoubleMaxValidator

      public DoubleMaxValidator(Double max)
      Constructor with default error message.
      Parameters:
      max - max value
    • DoubleMaxValidator

      public DoubleMaxValidator(Double max, String message)
      Constructor with custom error message. This message can contain '${value}', and '${max}' keys for formatted output.

      Example: "Value '${value}' should be greater than or equal to '${max}'".

      Parameters:
      max - max value
      message - error message
  • Method Details

    • setMessages

      @Autowired protected void setMessages(Messages messages)
    • setDatatypeRegistry

      @Autowired protected void setDatatypeRegistry(DatatypeRegistry datatypeRegistry)
    • setCurrentAuthentication

      @Autowired public void setCurrentAuthentication(CurrentAuthentication currentAuthentication)
    • setStringSubstitutor

      @Autowired public void setStringSubstitutor(StringSubstitutor substitutor)
    • setMax

      @StudioProperty(name="value", required=true) public void setMax(Double max)
      Sets max value.
      Parameters:
      max - max value
    • getMax

      public Double getMax()
      Returns:
      max value
    • setMax

      public void setMax(Double max, boolean inclusive)
      Sets max value and inclusive option.
      Parameters:
      max - max value
      inclusive - inclusive option
    • setInclusive

      @StudioProperty public void setInclusive(boolean inclusive)
      Set to true if the value must be greater than or equal to the specified maximum. Default value is true.
      Parameters:
      inclusive - inclusive option
    • isInclusive

      public boolean isInclusive()
      Returns:
      true if the value must be greater than or equal to the specified maximum
    • accept

      public void accept(T value) throws ValidationException
      Description copied from interface: Validator
      Checks a value.
      Parameters:
      value - a value
      Throws:
      ValidationException
    • getDefaultMessage

      protected String getDefaultMessage()
    • fireValidationException

      protected void fireValidationException(T value)