restrictTo

fun <T : Comparable<T>> ProcessedArgument<T, T>.restrictTo(min: T? = null, max: T? = null, clamp: Boolean = false): ProcessedArgument<T, T>

Restrict the argument values to fit into a range.

By default, conversion fails if the value is outside the range, but if clamp is true, the value will be silently clamped to fit in the range.

This must be called before transforms like pair, default, or multiple, since it checks each individual value.

Example:

argument().int().restrictTo(max=10, clamp=true).default(10)

Restrict the argument values to fit into a range.

By default, conversion fails if the value is outside the range, but if clamp is true, the value will be silently clamped to fit in the range.

This must be called before transforms like pair, default, or multiple, since it checks each individual value.

Example:

argument().int().restrictTo(1..10, clamp=true).default(10)

fun <T : Comparable<T>> OptionWithValues<T?, T, T>.restrictTo(min: T? = null, max: T? = null, clamp: Boolean = false): OptionWithValues<T?, T, T>

Restrict the option values to fit into a range.

By default, conversion fails if the value is outside the range, but if clamp is true, the value will be silently clamped to fit in the range.

This must be called before transforms like pair, default, or multiple, since it checks each individual value.

Example:

option().int().restrictTo(max=10, clamp=true).default(10)

fun <T : Comparable<T>> OptionWithValues<T?, T, T>.restrictTo(range: ClosedRange<T>, clamp: Boolean = false): OptionWithValues<T?, T, T>

Restrict the option values to fit into a range.

By default, conversion fails if the value is outside the range, but if clamp is true, the value will be silently clamped to fit in the range.

This must be called before transforms like pair, default, or multiple, since it checks each individual value.

Example:

option().int().restrictTo(1..10, clamp=true).default(10)