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

EctoErrorSerializer doesn't render errors from relationships and embedded objects #329

Open
lucasmazza opened this issue Aug 14, 2019 · 4 comments

Comments

@lucasmazza
Copy link

This was reported on #249 but the issue and PR are closed without being merged and released. EctoErrorSerializer.format/3 calls changeset.errors directly instead of using traverse_errors/2 to walk through the changeset data to collect nested errors and render properly. It is possible that we can bring this fix back?

@beerlington
Copy link
Contributor

I think it got missed as this project changed hands around that time and it just fell through the cracks. I'd definitely be interested in supporting that if there's a good use case for it. Without JSON API having good support for creating nested records in v1.0 of the spec, what is your use case? I just want to make sure I understand how it would be used so the tests reflect that.

@lucasmazza
Copy link
Author

@beerlington we have a schema with the following relationships:

defmodule MyApp.Client do
  use Ecto.Schema
  import Ecto.Changeset

  schema "clients" do
    has_many :addresses, MyApp.Address
    embeds_one :document, MyApp.Document
  end
end

Our API accepts the addresses and document properties inside the clients document, and we want to respond with the validation errors of those associations as expected. Ecto won't store the errors on the clients changeset, but we need to traverse the inner Changesets using traverse_errors to collect those errors when rendering it on the API.

@theoks
Copy link

theoks commented Aug 26, 2020

I would also be interested in seeing this implemented.

@tadast
Copy link

tadast commented Aug 26, 2020

What workarounds are you folks using until this is implemented?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants