ifNull

Sets a handler to be invoked when the configuration field is null or missing.

This method allows specifying a custom implementation of the ErrorHandlerWith interface that defines the behavior when a field is found to be null during validation or loading.

The handler can log warnings, throw exceptions, or provide fallback values.

Example:

field(AppConfig::apiKey).ifNull(LogWarningHandler::class)

Return

this FieldConfigScope for method chaining

Parameters

handler

the class of the custom error handler implementing ErrorHandlerWith


fun ifNull(handler: (Any?, Any?) -> Unit): FieldConfigScope<V>