Class PositiveOrZeroValidator<T extends Number>

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

@Component("ui_PositiveOrZeroValidator") @Scope("prototype") public class PositiveOrZeroValidator<T extends Number> extends AbstractValidator<T>
PositiveOrZero validator checks that value should be a greater than or equal to 0.

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

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

     @Bean("ui_PositiveOrZeroValidator")
     @Scope(BeanDefinition.SCOPE_PROTOTYPE)
     @Primary
     protected PositiveOrZeroValidator positiveOrZeroValidator() {
          return new CustomPositiveOrZeroValidator();
     }
 
  • Constructor Details

    • PositiveOrZeroValidator

      public PositiveOrZeroValidator()
    • PositiveOrZeroValidator

      public PositiveOrZeroValidator(String message)
      Constructor for custom error message. This message can contain '${value}' key for formatted output.

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

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

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