Add #removeError and #removeErrors to BufferedChangeset #189
+138
−0
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.
I'm using ember-changeset with ember-changeset-validations with some validations where the presence requirement of one field is dependent on the value of another. If the dependent field ends up with an error and then the field it depends on changes, the error should really be cleared. But it didn't seem like there was a clean way to do that without actually rolling back the property. This seems to have come up a number of times in issues and PRs.
This seems to be something that works in the newer
validated-changeset
4.x-5.x experiment, but is not something available in the classic BufferedChangeset.adopted-ember-addons/ember-changeset#361
adopted-ember-addons/ember-changeset#282
There were some workarounds in the above threads, like effectively "clearing" an error by
changeset.addError('email', null)
, but in my testing it still left the changeset with anisValid = false
state.This PR adds
removeError
andremoveErrors
to BufferedChangeset, mirroring the behavior in the newer ValidatedChangeset, and opening the door for anember-changeset
PR making this interface public.This also should address #170