isInPast
The validatable Instant must be in the past when this constraint is applied.
The comparison is made against the system clock Clock.System
. Use isBefore to compare against an arbitrary Instant.
Code example:
val validate = Validator<Instant> { isInPast() }
val now = Clock.System.now()
validate(now - 5.seconds) // Success
validate(now + 5.seconds) // Failure (message: Must be in the past)
The validatable LocalDate must be in the past when this constraint is applied.
The comparison is made against the system clock Clock.System
and time zone TimeZone.currentSystemDefault()
. Use isBefore to compare against an arbitrary LocalDate.
Code example:
val validate = Validator<LocalDate> { isInPast() }
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)
The validatable LocalTime must be in the past when this constraint is applied.
The comparison is made against the system clock Clock.System
and time zone TimeZone.currentSystemDefault()
. Use isBefore to compare against an arbitrary LocalTime.
Code example:
val validate = Validator<LocalTime> { isInPast() }
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)
The validatable LocalDateTime must be in the past when this constraint is applied.
The comparison is made against the system clock Clock.System
and time zone TimeZone.currentSystemDefault()
. Use isBefore to compare against an arbitrary LocalDateTime.
Code example:
val validate = Validator<LocalDateTime> { isInPast() }
val timezone = TimeZone.currentSystemDefault()
val now = Clock.System.now().toLocalDateTime(timezone)
validate((now.toInstant(timezone) - 5.seconds).toLocalDateTime(timezone)) // Success
validate((now.toInstant(timezone) + 5.seconds).toLocalDateTime(timezone)) // Failure (message: Must be in the past)