Class MinValidator<T extends Number>

java.lang.Object
io.jmix.ui.component.validation.AbstractValidator<T>
io.jmix.ui.component.validation.MinValidator<T>
Type Parameters:
T - BigDecimal, BigInteger, Long, Integer
All Implemented Interfaces:
Validator<T>, Consumer<T>

@Component("ui_MinValidator") @Scope("prototype") public class MinValidator<T extends Number> extends AbstractValidator<T>
Min 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_MinValidator")
     @Scope(BeanDefinition.SCOPE_PROTOTYPE)
     @Primary
     protected MinValidator minValidator(long min) {
          return new CustomMinValidator(min);
     }
 
  • Field Details

    • min

      protected long min
  • Constructor Details

    • MinValidator

      public MinValidator(long min)
    • MinValidator

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

      public long getMin()
      Returns:
      min value
    • accept

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