validate
Adds a custom validator for the configuration field.
Validators are lambda functions that perform additional validation on the field's value. If the validation fails, the validator should throw an exception (typically IllegalArgumentException).
Multiple validators can be added by calling this method multiple times.
Example:
field(AppConfig::port)
.validate { require(it > 0) { "Port must be positive" } }
.validate { require(it < 65536) { "Port must be less than 65536" } }Content copied to clipboard
Return
this FieldConfigScope for method chaining
Parameters
block
a lambda function that takes the field value and validates it