ValidatedProperty

open class ValidatedProperty<V>(initialValue: V, bean: Any? = null, beanName: String? = null, val validation: (ValidatedProperty<V>, V, V) -> V) : PropertyBase<V>

A Property whose value is validated before being set. Whenever value is changed, validation is called with the old and new values. validation returns a validated value.

validation takes 3 arguments (similar to ChangeListener :

  1. this property

  2. oldValue

  3. newValue

For example, to reject a value, keeping the old value :

val myStringProperty = ValidatedProperty("Hello") { _, old, new ->
    if (old.isBlank()) old else new
}

Inheritors

Constructors

Link copied to clipboard
constructor(initialValue: V, bean: Any? = null, beanName: String? = null, validation: (ValidatedProperty<V>, V, V) -> V)

Properties

Link copied to clipboard

The validation. Args :

Link copied to clipboard
open override var value: V