adopted-ember-addons / adopted-ember-addons/ember-changeset
Can no longer access model errors after failed save
- Langage dominant
- JavaScript
- Étoiles
- 425
- Forks
- 136
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
## Version
ember-changeset@3.10.2
validated-changeset@0.10.2
## Test Case
None
## Steps to reproduce
Set up a scenario where the server rejects a save with validation errors, as per this example in the readme:
```
changeset
.save()
.then(() => {
/* ... */
})
.catch(() => {
get(this, 'model.errors').forEach(({ attribute, message }) => {
changeset.addError(attribute, message);
});
});
```
## Expected Behavior
`model.errors` contains errors
## Actual Behavior
`model.errors` has no errors as original value has been restored on the model, wiping the errors out.
I believe this has been caused by this change:
https://github.com/validated-changeset/validated-changeset/pull/80
When the original value of an attribute is restored onto the model, the model clears the errors for that attribute. That means by the time the error is caught, `model.errors` contains no error messages.
It is therefore no longer possible to add model errors to a changeset.
The exception that Ember Data throws does not have the parsed errors on it - it has the raw JSON:API response. So there is no way to access the parsed Ember Data errors and push them into the changeset.
Guide de contribution
Ouvrir le guide de contribution
Évaluation
Cette issue n'a pas encore été évaluée.