Class DoubleMinValidator<T>

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

@Component("ui_DoubleMinValidator") @Scope("prototype") public class DoubleMinValidator<T> extends AbstractValidator<T>
Double validator checks that value must be greater than or equal to the specified minimum.

For error message it uses template string and it is possible to use '${value}' and '${min}' 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_DoubleMinValidator")
     @Scope(BeanDefinition.SCOPE_PROTOTYPE)
     @Primary
     protected DoubleMinValidator doubleMinValidator(Double min) {
          return new CustomDoubleMinValidator(min);
     }
 
  • Field Details

    • min

      protected Double min
    • inclusive

      protected boolean inclusive
  • Constructor Details

    • DoubleMinValidator

      public DoubleMinValidator(Double min)
      Constructor with default error message.
      Parameters:
      min - min value
    • DoubleMinValidator

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

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

      Parameters:
      min - min 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)
    • setMin

      @StudioProperty(name="value", required=true) public void setMin(Double min)
      Sets min value.
      Parameters:
      min - min value
    • getMin

      public Double getMin()
      Returns:
      min value
    • setMin

      public void setMin(Double min, boolean inclusive)
      Sets min value and inclusive option.
      Parameters:
      min - min 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 minimum. 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 minimum
    • 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)