Class DecimalMaxValidator<T>

java.lang.Object
io.jmix.ui.component.validation.AbstractValidator<T>
io.jmix.ui.component.validation.DecimalMaxValidator<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_DecimalMaxValidator") @Scope("prototype") public class DecimalMaxValidator<T> extends AbstractValidator<T>
DecimalMax validator checks that value must be less 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_DecimalMaxValidator")
     @Scope(BeanDefinition.SCOPE_PROTOTYPE)
     @Primary
     protected DecimalMaxValidator decimalMaxValidator(BigDecimal max) {
          return new CustomDecimalMaxValidator(max);
     }
 
  • Field Details

    • max

      protected BigDecimal max
    • inclusive

      protected boolean inclusive
  • Constructor Details

    • DecimalMaxValidator

      public DecimalMaxValidator(BigDecimal max)
      Constructor with default error message.
      Parameters:
      max - max value
    • DecimalMaxValidator

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

      Example: "Value '${value}' should be less 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(BigDecimal max)
      Sets max value.
      Parameters:
      max - max value
    • getMax

      public BigDecimal getMax()
      Returns:
      max value
    • setMax

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