ValidatorDsl

class ValidatorDsl(val state: State)(source)

A domain-specific language (DSL) for creating Validators on a State object.

Parameters

state

the State that this DSL creates Validators for. This State is not modified by the DSL itself

See also

Constructors

Link copied to clipboard
private constructor(state: State)

Types

Link copied to clipboard
object Companion

Holds constants.

Link copied to clipboard
inner class OfDsl<T>(val property: KProperty<T>)

A domain-specific language (DSL) for creating Validators for a specific property.

Properties

Link copied to clipboard
private val state: State
Link copied to clipboard
private val validators: MutableList<Validator<*>>

The list of Validators that has been created inside the DSL thus far.

Functions

Link copied to clipboard
fun <S : State> include(property: KProperty<S>, condition: () -> Boolean = { true })

Includes all Validators of the given property, but skips them during validation when condition is false.

Link copied to clipboard
fun <T> of(property: KProperty<T>): ValidatorDsl.OfDsl<T>

Enters a DSL for constructing Validators for the given property.

Link copied to clipboard
private fun <T> validator(property: KProperty<T>, validate: (T) -> ValidationInfo?): Validator<T>

Wraps around the default Validator constructor, but additionally adds the created Validator to validators.