Range

annotation class Range(val min: Double, val max: Double)

Constrains a numeric configuration field to an inclusive range between min and max.

When a configuration is loaded, the field value is validated to ensure it falls within the specified bounds. Works with all numeric types (Int, Long, Float, Double). If the value is outside the range, a validation error is raised.

Usage:

data class ServerConfig(
@Range(min = 1.0, max = 65535.0)
val port: Int = 8080,

@Range(min = 0.0, max = 1.0)
val loadFactor: Double = 0.75,

@Range(min = 1.0, max = 1000.0)
val maxPlayers: Int = 200
)

Since

1.0

See also

Properties

Link copied to clipboard
val max: Double

The maximum allowed value (inclusive).

Link copied to clipboard
val min: Double

The minimum allowed value (inclusive).