ValidatorFX icon indicating copy to clipboard operation
ValidatorFX copied to clipboard

Allow iteration over all dependencies in a check

Open effad opened this issue 3 years ago • 0 comments

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.

effad avatar Sep 29 '22 08:09 effad