mvvmfx-validation/src/main/java/de/saxsys/mvvmfx/utils/validation/ObservableRuleBasedValidator.java
public void addRule(ObservableValue<ValidationMessage> rule) {
        complexRules.add(rule);

        rule.addListener((observable, oldValue, newValue) -> {
            if(oldValue != null) {
               validationStatus.removeMessage(oldValue);
            }
            if(newValue != null) {
                validationStatus.addMessage(newValue);
            }
        });

        if(rule.getValue() != null) {
            validationStatus.addMessage(rule.getValue());
        }
    }
public void addRule(ObservableValue<ValidationMessage> rule) {
        complexRules.add(rule);

        rule.addListener((observable, oldValue, newValue) -> {
            if(oldValue != null) {
               validationStatus.removeMessage(oldValue);
            }
            if(newValue != null) {
                validationStatus.addMessage(newValue);
            }
        });

        if(rule.getValue() != null) {
            validationStatus.addMessage(rule.getValue());
        }
    }
Add a complex rule for this validator.
<p>
The rule is defined by an {@link ObservableValue}. If this observable contains a {@link ValidationMessage}
object the rule is considered to be violated and the {@link ValidationStatus} of this validator will contain
the validation message object contained in the observable value.
If the observable doesn't contain a value (in other words it contains <code>null</code>) the rule is considered to
be fulfilled and the validation status of this validator will be valid (given that no other rule is violated).
<p>

This method allows some more complex rules compared to {@link #addRule(ObservableValue, ValidationMessage)}.
This way you can define rules that have different messages for specific cases.

@param rule