Run refiners as long as validators passed #1068
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously refiners ran only when there were no past failures during
validation of the value itself or its subvalues. This behavior was
causing inferior UX when validating forms with additional validations
defined as refiners. If there was a refinement error in some subfield,
the refiners defined on the parent of that subfield were not executed.
Only after fixing the error in the subfield did the user receive
information about the failure on the parent field.
This commit changes the condition under which refinements are run.
Refinements are executed if there were no previous failures or those
failures came exclusively from other refiners.
The change helps in the form validation scenario because as long as the
form structure is valid (which is checked using
validator
s), failuresfrom all refiners are collected.
Refiners still run only if the general structure of the value is
correct. They will get passed a structurally-valid value. The only
difference now is that those values were may not have been checked via a
refiner.
If some check is so important that other refiners should not
run if that check fails, that check should be defined as a
validator
,not a
refiner
. Failing that check will not run other refiners.Fixes #979