FieldTypeAdapter
An adapter interface for converting between different type representations of a field value.
This interface enables type conversion between:
V: The stored value type in the form data
S: The validation target type (what validators operate on)
U: The input/display type (what the UI components work with)
This is useful when you need to validate or display a field value in a different format than how it's stored. For example, storing an integer but displaying it as a string in a text field.
Usage:
class IntStringAdapter : FieldTypeAdapter<Int, String, String> {
override fun toValidationTarget(value: Int): String = value.toString()
override fun toInput(value: Int): String = value.toString()
override fun fromInput(value: String, current: Int): Int = value.toIntOrNull() ?: current
}
Content copied to clipboard
Parameters
V
The type of the value as stored in the form data.
S
The type used for validation.
U
The type used for input/display in UI components.