From 40b1bedbe22586130748a2efb4372fb938bd9dc3 Mon Sep 17 00:00:00 2001 From: Thelonius Kort Date: Fri, 30 Dec 2022 21:17:46 +0100 Subject: [PATCH] Add article_id to Translation validations --- lib/outlook/translations/translation.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/outlook/translations/translation.ex b/lib/outlook/translations/translation.ex index 225cd1f..3d9fd16 100644 --- a/lib/outlook/translations/translation.ex +++ b/lib/outlook/translations/translation.ex @@ -23,9 +23,9 @@ defmodule Outlook.Translations.Translation do @doc false def changeset(translation, attrs) do translation - |> cast(attrs, [:lang, :title, :teaser, :date, :public, :unauthorized]) + |> cast(attrs, [:lang, :title, :teaser, :date, :public, :unauthorized, :article_id]) |> cast(attrs, [:content], force_changes: true) - |> validate_required([:lang, :title, :teaser, :content, :date, :public, :unauthorized]) + |> validate_required([:lang, :title, :content, :date, :public, :unauthorized, :article_id]) |> unique_constraint([:lang, :article_id], message: "translation for this language already exists", name: :article_id_lang_unique_index)