Class PastOrPresentValidator<T>

java.lang.Object
io.jmix.ui.component.validation.AbstractValidator<T>
io.jmix.ui.component.validation.PastOrPresentValidator<T>
Type Parameters:
T - Date, LocalDate, LocalDateTime, LocalTime, OffsetDateTime, OffsetTime
All Implemented Interfaces:
Validator<T>, Consumer<T>

@Component("ui_PastOrPresentValidator") @Scope("prototype") public class PastOrPresentValidator<T> extends AbstractValidator<T>
Validates that date or time in the past or present.

Note, types that support TimeZones can be found in DateTimeTransformations.isDateTypeSupportsTimeZones(Class)

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

     @Bean("ui_PastOrPresentValidator")
     @Scope(BeanDefinition.SCOPE_PROTOTYPE)
     @Primary
     protected PastOrPresentValidator pastOrPresentValidator() {
          return new CustomPastOrPresentValidator();
     }
 
  • Field Details

    • timeSource

      protected TimeSource timeSource
    • checkSeconds

      protected boolean checkSeconds
  • Constructor Details

    • PastOrPresentValidator

      public PastOrPresentValidator()
    • PastOrPresentValidator

      public PastOrPresentValidator(String message)
      Constructor for custom error message.
      Parameters:
      message - error message
  • Method Details

    • setMessages

      @Autowired protected void setMessages(Messages messages)
    • setTimeSource

      @Autowired protected void setTimeSource(TimeSource timeSource)
    • setCheckSeconds

      @StudioProperty public void setCheckSeconds(boolean checkSeconds)
      Set true if validator should also check seconds and nanos (if supported) in value. Default value is false.
      Parameters:
      checkSeconds - check seconds
    • isCheckSeconds

      public boolean isCheckSeconds()
      Returns:
      true if seconds and nanos are checked
    • accept

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