KbTransformScope

sealed interface KbTransformScope(source)

The receiver scope inside a KbTransform lambda. Exposes coercion helpers and the active KpaElementFactory so transforms can read inputs as Kotlin types and produce typed KpaElement results without hard-coding an adapter family.

This interface is sealed: consumer code receives a KbTransformScope as the receiver inside a transform body and cannot implement it directly. Sealing lets new members be added in future versions without breaking binary compatibility for consumers.

Properties

Link copied to clipboard
abstract val factory: KpaElementFactory

The factory for the adapter family in use for the current render.

Functions

Link copied to clipboard
Link copied to clipboard
fun KbTransformScope.asElement(value: KbTransformable?): KpaElement?

Extracts the wrapped KpaElement from value, or null when value is null.

Link copied to clipboard

Coerces element to an Int by routing through asString then toIntOrNull, returning null when the string is not a valid integer representation.

Link copied to clipboard
fun KbTransformScope.asList(value: KbTransformable?): KpaList?

Extracts the wrapped KpaList from value, or null when value is null or wraps a non-list element.

Link copied to clipboard

Coerces element to a Double when it wraps a numeric primitive or a numeric-string primitive; null otherwise.

Link copied to clipboard
abstract fun asString(input: KpaElement?): String

Coerces input to its rendered string form using the same rule as {{ identifier }}:

Link copied to clipboard

Coerces value to its rendered string form using the same rule as {{ identifier }}.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun KbTransformScope.element(value: KpaElement?): KbTransformable?

Null-safely wraps value as a KbTransformable, returning null when value is null.

Link copied to clipboard
fun KbTransformScope.list(items: List<KpaElement>): KbTransformable

Wraps items as a list KbTransformable using the active KbTransformScope.factory.

Link copied to clipboard
Link copied to clipboard
abstract fun softFail(category: KbSoftFailEvent.Category, problem: String, input: KbTransformable?): KbTransformable?

Reports a soft failure for the value currently being transformed and returns null to propagate the missing value.

Link copied to clipboard