Field

interface Field<V>

A field is a single input in a form. It has a name, a value, and a set of errors.

Parameters

V

The type of the value of the field.

Properties

Link copied to clipboard
abstract val errors: FieldErrors

The errors of the field. If the field has no errors, this should be an empty list.

Link copied to clipboard
open val hasError: Boolean

Returns true if the field has errors, false otherwise.

Link copied to clipboard
abstract val isDirty: Boolean

Returns true if the field is dirty, false otherwise. A field is dirty if its value has changed since the initial value.

Link copied to clipboard
abstract val isEnabled: Boolean

Returns true if the field is enabled, false otherwise. A field is enabled if it is not disabled.

Link copied to clipboard
abstract val isFocused: Boolean

Returns true if the field is focused, false otherwise. Sets to focused when the field gains focus.

Link copied to clipboard
abstract val isTouched: Boolean

Returns true if the field is touched, false otherwise. Sets to touched when the field loses focus after being focused.

Link copied to clipboard
abstract val name: FieldName

The name of the field.

Link copied to clipboard
abstract val onBlur: () -> Unit

Callback to notify when the field loses focus.

Link copied to clipboard
abstract val onChange: (V) -> Unit

Callback to notify when the value of the field is changed.

Link copied to clipboard
abstract val onFocus: () -> Unit

Callback to notify when the field gains focus.

Link copied to clipboard
abstract val value: V

The value of the field.

Functions

Link copied to clipboard
abstract fun virtualTrigger(validateOn: FieldValidateOn)

Triggers validation of the field.