ValidatorFX
ValidatorFX copied to clipboard
Allow iteration over all dependencies in a check
Consider the case where a check is programmatically built out of a set of objects, e.g.
Check check = validator.createCheck()
.withMethod(this::atLeastOneParameter);
for (ComboFormField<?> combo : combos.values()) {
check
.dependsOn(combo.getDataIndex(), combo.chosenItemProperty())
.decorates(combo.getPresentation())
;
}
check.immediate()
Now in the check-Method we must iterate over all the given properties to check if at least one value was given, but there is no way to do that easily:
private void atLeastOneParameter(Check.Context check) {
// TODO :: iterate over all dependencies
}
We must iterate over combos again and pick the same property, which violates the DRY principle and inserts an ugly dependency between the two places in the code.