Pattern

annotation class Pattern(val regex: String, val description: String = "")

Validates that a string configuration field matches the given regular expression.

When a configuration is loaded, the field value is checked against regex. If it does not match, a validation error is raised. An optional description can be provided to give users a human-readable explanation of the expected format.

Usage:

data class NetworkConfig(
@Pattern(
regex = "^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}$",
description = "Must be a valid IPv4 address"
)
val bindAddress: String = "0.0.0.0",

@Pattern(regex = "^[a-z][a-z0-9-]*$")
val hostname: String = "app-server"
)

Since

1.0

See also

Properties

Link copied to clipboard

An optional human-readable description of the expected format, used in validation error messages. Defaults to an empty string.

Link copied to clipboard

The regular expression the field value must match.