Class DecimalMinValidator<T>

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

@Component("ui_DecimalMinValidator") @Scope("prototype") public class DecimalMinValidator<T> extends AbstractValidator<T>
DecimalMin 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_DecimalMinValidator")
     @Scope(BeanDefinition.SCOPE_PROTOTYPE)
     @Primary
     protected DecimalMinValidator decimalMinValidator(BigDecimal min) {
          return new CustomDecimalMinValidator(min);
     }
 
  • Field Details

    • min

      protected BigDecimal min
    • inclusive

      protected boolean inclusive
  • Constructor Details

    • DecimalMinValidator

      public DecimalMinValidator(BigDecimal min)
      Constructor with default error message.
      Parameters:
      min - min value
    • DecimalMinValidator

      public DecimalMinValidator(BigDecimal 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(BigDecimal min)
      Sets min value.
      Parameters:
      min - min value
    • getMin

      public BigDecimal getMin()
      Returns:
      min value
    • setMin

      public void setMin(BigDecimal 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)