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 :
this
propertyoldValue
newValue
For example, to reject a value, keeping the old value :
val myStringProperty = ValidatedProperty("Hello") { _, old, new ->
if (old.isBlank()) old else new
}
Content copied to clipboard