ControlValidator

abstract class ControlValidator<T : Any>

Abstract base class of all form control validators.

A validator is responsible for:

  • Checking control visibility based on dependencies

  • Determining whether fields are required, depending on conditions

  • Basic validation (required, empty state)

  • Validation specific to the control type

Every control type has its own validator extending this class and implementing validateSpecific() for its specific rules.

Type Parameters

T

type of the data held by the control

Inheritors

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
protected lateinit var errorManager: ErrorManager
Link copied to clipboard
protected lateinit var formSchema: FormSchema
Link copied to clipboard
protected lateinit var formState: FormState

Functions

Link copied to clipboard
internal fun isControlRequired(control: Control<*>, controlContext: ControlContext): Boolean

Checks whether the control is required, based on its configuration and dependencies.

Link copied to clipboard
internal fun isControlVisible(control: Control<*>, controlContext: ControlContext): Boolean
Link copied to clipboard
private fun isDependencyMet(dependency: ControlDependency<*>, controlContext: ControlContext): Boolean
Link copied to clipboard
internal fun isValueEmpty(value: Any?): Boolean

Checks whether the value is empty or not filled in.

Link copied to clipboard
internal open fun setupFormReferences(formState: FormState, formSchema: FormSchema, errorManager: ErrorManager)

Sets the form component references for the validator.

Link copied to clipboard
open fun validate(controlContext: ControlContext, state: ControlState<*>, control: Control<*>)

Main validation method of a control.

Link copied to clipboard
abstract fun validateSpecific(controlContext: ControlContext, value: T)

Validation specific to the control type, run for a non-null value.