isAfterOrEqualTo

fun Validatable<Instant?>.isAfterOrEqualTo(other: Instant): Constraint

The validatable Instant must be after or equal to other when this constraint is applied.

Use isInFutureOrIsPresent to compare against the system clock Clock.System.

Code example:

val now = Instant.parse("2024-08-31T12:30:15Z")
val validate = Validator<Instant> { isAfterOrEqualTo(now) }
validate(now + 5.seconds) // Success
validate(now) // Success
validate(now - 5.seconds) // Failure (message: Must be after or equal to "2024-08-31T12:30:15Z")

fun Validatable<LocalDate?>.isAfterOrEqualTo(other: LocalDate): Constraint

The validatable LocalDate must be after or equal to other when this constraint is applied.

Use isInFutureOrIsPresent to compare against the system clock Clock.System.

Code example:

val now = LocalDate.parse("2024-08-31")
val validate = Validator<LocalDate> { isAfterOrEqualTo(now) }
validate(now.plus(2, DateTimeUnit.DAY)) // Success
validate(now) // Success
validate(now.minus(2, DateTimeUnit.DAY)) // Failure (message: Must be after or equal to "2024-08-31")

fun Validatable<LocalTime?>.isAfterOrEqualTo(other: LocalTime): Constraint

The validatable LocalTime must be after or equal to other when this constraint is applied.

Use isInFutureOrIsPresent to compare against the system clock Clock.System.

Code example:

val now = LocalTime.parse("12:30:15")
val validate = Validator<LocalTime> { isAfterOrEqualTo(now) }
validate(LocalTime.fromSecondOfDay(now.toSecondOfDay() + 5)) // Success
validate(now) // Success
validate(LocalTime.fromSecondOfDay(now.toSecondOfDay() - 5)) // Failure (message: Must be after or equal to "12:30:15")

fun Validatable<LocalDateTime?>.isAfterOrEqualTo(other: LocalDateTime): Constraint

The validatable LocalDateTime must be after or equal to other when this constraint is applied.

Use isInFutureOrIsPresent to compare against the system clock Clock.System.

Code example:

val now = LocalDateTime.parse("2024-08-31T12:30:15")
val timezone = TimeZone.currentSystemDefault()
val validate = Validator<LocalDateTime> { isAfterOrEqualTo(now) }
validate((now.toInstant(timezone) + 5.seconds).toLocalDateTime(timezone)) // Success
validate(now) // Success
validate((now.toInstant(timezone) - 5.seconds).toLocalDateTime(timezone)) // Failure (message: Must be after or equal to "2024-08-31T12:30:15")