field(:author_name, :string) field(:published, :boolean) field(:title, :map) end def changeset(%__MODULE__{} = record, params) do record |> cast(~w(author_name published title)a, params) |> validate_required(~w(author_name title)a) |> validate_change(:title, &validate_nested_french_value/2) end defp validate_nested_french_value(field, %{"fr" => fr}) when fr != "", do: [] defp validate_nested_french_value(field, _) do [{field, "must specify french value"}] end end
field(:gateway_response, :map) belongs_to(:order_id, App.Order) end def changeset(%__MODULE__{} = record, params) do record |> cast(~w(order_id gateway_response)a, params) |> validate_required(~w(order_id)a) end end
:string) field(:fr, :string) end def changeset(%__MODULE__{} = record, params) do record |> cast(~w(en fr)a, params) |> validate_required(~w(fr)a) end end
true, title: %App.Translations.Translated{ id: "602975a2-bfbd-4c48-9d60-0b955ccc4bc7", en: "My new article in english", fr: "Mon nouvel article en français" } }