How exactly i can add an error into nested/embedded changeset? Don’t think add_error can do this.
Context: regular changeset validation already happened and i’m doing some external check
e.g.
...
defmodule Thing do
schema "things" do
embeds_one :config, ThingConfig, on_replace: :update
end
end
...
defmodule ThingConfig do
@primary_key false
embedded_schema do
field :param, :string
end
end
# ??
ch1 = Ecto.Changeset.add_error(ch.changes.config, :param, "error")
# ??????
Ecto.Changeset.put_embed(ch, :config, ch1)
on insert it works, on update - error:
Since you have set
:on_replace
to:update
, you are only allowed
to update the existing entry by giving updated fields as a map or
keyword list or set it to nil.