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