tornadofx / tornadofx / javafx.beans.property.Property / addValidator

addValidator

inline fun <reified T> Property<T>.addValidator(node: Node, trigger: ValidationTrigger = ValidationTrigger.OnChange(), noinline validator: ValidationContext.(T?) -> ValidationMessage?): <ERROR CLASS>

Add the given validator to a property that resides inside a ViewModel. The supplied node will be decorated by the current decorationProvider for this context inside the ViewModel of the property if validation fails.

The validator function is executed in the scope of this ValidationContext to give access to other fields and shortcuts like the error and warning functions.

The validation trigger decides when the validation is applied. ValidationTrigger.OnBlur tracks focus on the supplied node while OnChange tracks changes to the property itself.