Field Config Scope
Provides a DSL-style builder to configure fields in a configuration schema.
This class supports both method chaining and block-style configuration, allowing flexible and type-safe field definitions.
Method Chaining Style
def.field(AppConfig::port)
.default(8080)
.range(1..65535)
.validate { require(it > 0) { "Port must be positive" } }Block Style
def.field(AppConfig::apiKey) {
required()
validate { require(it.isNotBlank()) { "API key cannot be blank" } }
}Mixed Style
Both styles can be combined as needed:
def.field(AppConfig::timeout)
.default(30)
.range(1L..300L)Parameters
the type of the value associated with this field
Functions
Sets the default value for the configuration field.
Sets a handler to be invoked when the configuration field is null or missing.
Sets a custom loader for the configuration field.
Specifies the YAML/JSON key name for this field if it differs from the property name.
Validates that a String field is not blank (not empty and not just whitespace).
Marks the field as required or soft-required during configuration validation.
Shortcut method to mark a field as required and provide a default value.
Adds multiple validators at once.