Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run refiners as long as validators passed #1068

Merged
merged 2 commits into from
Jun 6, 2022
Merged

Run refiners as long as validators passed #1068

merged 2 commits into from
Jun 6, 2022

Conversation

Gelio
Copy link
Contributor

@Gelio Gelio commented Jun 5, 2022

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 validators), failures
from 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

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), failures
from 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
@ianstormtaylor ianstormtaylor added ✶ breaking Changes that would mean a breaking API change improvement labels Jun 6, 2022
@ianstormtaylor ianstormtaylor merged commit d1508a9 into ianstormtaylor:main Jun 6, 2022
@ianstormtaylor
Copy link
Owner

Thanks @Gelio!

@Gelio Gelio deleted the run-refiners-when-no-validator-errors branch June 6, 2022 13:43
@Gelio
Copy link
Contributor Author

Gelio commented Jun 6, 2022

Awesome, thanks for merging the PR (and the cleanup 😅 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✶ breaking Changes that would mean a breaking API change improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refinement for top level object failed when field has refinement
2 participants