isInFutureOrIsPresent

@JvmName(name = "instantIsInFutureOrIsPresent")
fun Validatable<Instant?>.isInFutureOrIsPresent(): Constraint

The validatable Instant must be in the future or present time when this constraint is applied.

The comparison is made against the system clock Clock.System. Use isAfterOrEqualTo to compare against an arbitrary Instant.

Code example:

val validate = Validator<Instant> { isInFutureOrIsPresent() }
val now = Clock.System.now()
validate(now + 5.seconds) // Success
validate(now - 5.seconds) // Failure (message: Must be in the future or present)

@JvmName(name = "localDateIsInFutureOrIsPresent")
fun Validatable<LocalDate?>.isInFutureOrIsPresent(): Constraint

The validatable LocalDate must be in the future or present time when this constraint is applied.

The comparison is made against the system clock Clock.System and time zone TimeZone.currentSystemDefault(). Use isAfterOrEqualTo to compare against an arbitrary LocalDate.

Code example:

val validate = Validator<LocalDate> { isInFutureOrIsPresent() }
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 or present)

@JvmName(name = "localTimeIsInFutureOrIsPresent")
fun Validatable<LocalTime?>.isInFutureOrIsPresent(): Constraint

The validatable LocalTime must be in the future or present time when this constraint is applied.

The comparison is made against the system clock Clock.System and time zone TimeZone.currentSystemDefault(). Use isAfterOrEqualTo to compare against an arbitrary LocalTime.

Code example:

val validate = Validator<LocalTime> { isInFutureOrIsPresent() }
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 or present)

@JvmName(name = "localDateTimeIsInFutureOrIsPresent")
fun Validatable<LocalDateTime?>.isInFutureOrIsPresent(): Constraint

The validatable LocalDateTime must be in the future or present time when this constraint is applied.

The comparison is made against the system clock Clock.System and time zone TimeZone.currentSystemDefault(). Use isAfterOrEqualTo to compare against an arbitrary LocalDateTime.

Code example:

val validate = Validator<LocalDateTime> { isInFutureOrIsPresent() }
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 or present)