isInPastOrIsPresent
The validatable Instant must be in the past or present time when this constraint is applied.
The comparison is made against the system clock Clock.System
. Use isBeforeOrEqualTo to compare against an arbitrary Instant.
Code example:
val validate = Validator<Instant> { isInPastOrIsPresent() }
val now = Clock.System.now()
validate(now - 5.seconds) // Success
validate(now + 5.seconds) // Failure (message: Must be in the past or present)
The validatable LocalDate must be in the past or present time when this constraint is applied.
The comparison is made against the system clock Clock.System
and time zone TimeZone.currentSystemDefault()
. Use isBeforeOrEqualTo to compare against an arbitrary LocalDate.
Code example:
val validate = Validator<LocalDate> { isInPastOrIsPresent() }
val now = Clock.System.now().toLocalDateTime(TimeZone.currentSystemDefault()).date
validate(now.minus(2, DateTimeUnit.DAY)) // Success
validate(now.plus(2, DateTimeUnit.DAY)) // Failure (message: Must be in the past or present)
The validatable LocalTime must be in the past or present time when this constraint is applied.
The comparison is made against the system clock Clock.System
and time zone TimeZone.currentSystemDefault()
. Use isBeforeOrEqualTo to compare against an arbitrary LocalTime.
Code example:
val validate = Validator<LocalTime> { isInPastOrIsPresent() }
val now = Clock.System.now().toLocalDateTime(TimeZone.currentSystemDefault()).time
validate(LocalTime.fromSecondOfDay(now.toSecondOfDay() - 5)) // Success
validate(LocalTime.fromSecondOfDay(now.toSecondOfDay() + 5)) // Failure (message: Must be in the past or present)
The validatable LocalDateTime must be in the past or present time when this constraint is applied.
The comparison is made against the system clock Clock.System
and time zone TimeZone.currentSystemDefault()
. Use isBeforeOrEqualTo to compare against an arbitrary LocalDateTime.
Code example:
val validate = Validator<LocalDateTime> { isInPastOrIsPresent() }
val timezone = TimeZone.currentSystemDefault()
val now = Clock.System.now().toLocalDateTime(TimeZone.currentSystemDefault())
validate((now.toInstant(timezone) - 5.seconds).toLocalDateTime(timezone)) // Success
validate((now.toInstant(timezone) + 5.seconds).toLocalDateTime(timezone)) // Failure (message: Must be in the past or present)