FieldControl

class FieldControl<V>(val name: FieldName, val policy: FieldPolicy, val rule: FormRule<V>, val defaultValue: V, val getValue: () -> V, val setValue: (V) -> Unit, val getErrors: () -> FieldErrors, val setErrors: (FieldErrors) -> Unit, val shouldTrigger: (FieldValidateOn) -> Boolean, val isEnabled: () -> Boolean)

Represents a field control in a form.

Parameters

V

The type of the field value.

Constructors

Link copied to clipboard
constructor(name: FieldName, policy: FieldPolicy, rule: FormRule<V>, defaultValue: V, getValue: () -> V, setValue: (V) -> Unit, getErrors: () -> FieldErrors, setErrors: (FieldErrors) -> Unit, shouldTrigger: (FieldValidateOn) -> Boolean, isEnabled: () -> Boolean)

Properties

Link copied to clipboard

The default value of the field.

Link copied to clipboard

The function to get the current field errors.

Link copied to clipboard
val getValue: () -> V

The function to get the current field value.

Link copied to clipboard
val isEnabled: () -> Boolean

The function to determine if the field is enabled.

Link copied to clipboard

The name of the field.

Link copied to clipboard

The policy of the field.

Link copied to clipboard

The rule to validate the field value.

Link copied to clipboard

The function to set the new field errors. If the new errors are empty, the field is considered valid.

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

The function to set the new field value.

Link copied to clipboard

The function to determine if the field should trigger validation on the given event.

Functions

Link copied to clipboard
fun validate(value: V = getValue(), dryRun: Boolean = false): Boolean

Validates the field value.