public class ObservableRuleBasedValidator extends Object implements Validator
Validator
implementation uses observable boolean values as rules. In comparison to the
FunctionBasedValidator
with this implementation more complex validation logic can be implemented.
It is useful for use cases where:
You can add multiple rules via the addRule(ObservableValue, ValidationMessage)
method. Each rule is an
observable boolean value. If the rule evaluates to true
it is considered to be "valid" and no message
will be present in the ValidationStatus
(getValidationStatus()
). If the rule evaluates to
false
it is considered to be "invalid". In this case the given ValidationMessage
will be
present.
If multiple rules are violated, each message will be present.
Constructor and Description |
---|
ObservableRuleBasedValidator() |
Modifier and Type | Method and Description |
---|---|
void |
addRule(javafx.beans.value.ObservableValue<Boolean> rule,
ValidationMessage message)
Add a rule for this validator.
|
ValidationStatus |
getValidationStatus()
Returns the validation status of this validator.
|
public void addRule(javafx.beans.value.ObservableValue<Boolean> rule, ValidationMessage message)
The rule defines a condition that has to be fulfilled.
A rule is defined by an observable boolean value. If the rule has a value of true
the rule is
"fulfilled". If the rule has a value of false
the rule is violated. In this case the given message
object will be added to the status of this validator.
There are some predefined rules for common use cases in the ObservableRules
class that can be used.
rule
- message
- public ValidationStatus getValidationStatus()
Validator
getValidationStatus
in interface Validator
Copyright © 2015 Saxonia Systems AG. All rights reserved.