Add article_id to Translation validations
This commit is contained in:
@ -23,9 +23,9 @@ defmodule Outlook.Translations.Translation do
|
|||||||
@doc false
|
@doc false
|
||||||
def changeset(translation, attrs) do
|
def changeset(translation, attrs) do
|
||||||
translation
|
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)
|
|> 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],
|
|> unique_constraint([:lang, :article_id],
|
||||||
message: "translation for this language already exists",
|
message: "translation for this language already exists",
|
||||||
name: :article_id_lang_unique_index)
|
name: :article_id_lang_unique_index)
|
||||||
|
|||||||
Reference in New Issue
Block a user