isAfter

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

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

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

Code example:

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

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

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

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

Code example:

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

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

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

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

Code example:

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

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

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

Use isInFuture 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> { isAfter(now) }
validate((now.toInstant(timezone) + 5.seconds).toLocalDateTime(timezone)) // Success
validate(now) // Failure (message: Must be after "2024-08-31T12:30:15")
validate((now.toInstant(timezone) - 5.seconds).toLocalDateTime(timezone)) // Failure (message: Must be after "2024-08-31T12:30:15")