> ## Documentation Index
> Fetch the complete documentation index at: https://validity-kt.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Durations

> Range constraints for kotlin.time.Duration and java.time.Duration.

The range constraints of lengths of time, for both `kotlin.time.Duration`, with arguments such as `15.minutes`,
and `java.time.Duration`, with arguments such as `Duration.ofDays(1)`.

> [!NOTE]
>
> A `null` argument checks nothing. A rule that reads a value that may be missing, such as `max(customer.limit)`,
> never fails because of it: `required` on that value reports it once.

```kotlin Meeting.kt theme={null}
data class Meeting(
    val length: Duration?,
    val reminderBefore: java.time.Duration?
) : Validatable {
    override fun validation() = validation {
        ::length required { between(min = 15.minutes, max = 4.hours) }
        ::reminderBefore required { max(java.time.Duration.ofDays(1)) }
    }
}
```

| Constraint | Checks |
| - | - |
| [`min`](#min) | Is at least `min`. |
| [`max`](#max) | Is at most `max`. |
| [`greaterThan`](#greaterthan) | Is greater than `other`. |
| [`lessThan`](#lessthan) | Is less than `other`. |
| [`between`](#between) | Is between `min` and `max`, both included. |

### `min`

`min(min)` on `kotlin.time.Duration`, `java.time.Duration`

Checks that the duration is at least `min`.

**Code** `min`· **Message** `must be at least {min}` · **Change it** `min = "…"`

### `max`

`max(max)` on `kotlin.time.Duration`, `java.time.Duration`

Checks that the duration is at most `max`.

**Code** `max`· **Message** `must be at most {max}` · **Change it** `max = "…"`

### `greaterThan`

`greaterThan(other)` on `kotlin.time.Duration`, `java.time.Duration`

Checks that the duration is greater than `other`.

**Code** `greaterThan`· **Message** `must be greater than {other}` · **Change it** `greaterThan = "…"`

### `lessThan`

`lessThan(other)` on `kotlin.time.Duration`, `java.time.Duration`

Checks that the duration is less than `other`.

**Code** `lessThan`· **Message** `must be less than {other}` · **Change it** `lessThan = "…"`

### `between`

`between(min, max)` on `kotlin.time.Duration`, `java.time.Duration`

Checks that the duration is between `min` and `max`, both included.

**Code** `between`· **Message** `must be between {min} and {max}` · **Change it** `between = "…"`


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.