isBetween
The validatable Duration must be in range (lower and upper bounds included) when this constraint is applied.
Code example:
val validate = Validator<Duration> {
val max = 10.seconds
isBetween(Duration.ZERO..max)
}
validate(5.seconds) // Success
validate(10.seconds) // Success
validate(15.seconds) // Failure (message: Must be between 0s and 10s (inclusive))
Content copied to clipboard
The validatable Duration must be in range (upper bound excluded) when this constraint is applied.
Code example:
val validate = Validator<Duration> {
val max = 10.seconds
isBetween(Duration.ZERO..<max)
}
validate(5.seconds) // Success
validate(10.seconds) // Failure (message: Must be between 0s and 10s (exclusive))
validate(15.seconds) // Failure (message: Must be between 0s and 10s (exclusive))
Content copied to clipboard