diff --git a/app/models/organisation_relationship.rb b/app/models/organisation_relationship.rb index e03b52530..7f3a85cae 100644 --- a/app/models/organisation_relationship.rb +++ b/app/models/organisation_relationship.rb @@ -1,17 +1,17 @@ class OrganisationRelationship < ApplicationRecord belongs_to :child_organisation, class_name: "Organisation" belongs_to :parent_organisation, class_name: "Organisation" - validates :parent_organisation_id, presence: { message: "You must choose a housing provider" } - validates :child_organisation_id, presence: { message: "You must choose a managing agent" } - validates :parent_organisation_id, uniqueness: { scope: :child_organisation_id, message: "You have already added this housing provider" } - validates :child_organisation_id, uniqueness: { scope: :parent_organisation_id, message: "You have already added this managing agent" } + validates :parent_organisation_id, presence: { message: I18n.t("validations.organisation.housing_provider.blank") } + validates :child_organisation_id, presence: { message: I18n.t("validations.organisation.managing_agent.blank") } + validates :parent_organisation_id, uniqueness: { scope: :child_organisation_id, message: I18n.t("validations.organisation.housing_provider.already_added") } + validates :child_organisation_id, uniqueness: { scope: :parent_organisation_id, message: I18n.t("validations.organisation.managing_agent.already_added") } validate :validate_housing_provider_owns_stock, on: :housing_provider private def validate_housing_provider_owns_stock if parent_organisation_id.present? && !parent_organisation.holds_own_stock - errors.add :parent_organisation_id, I18n.t("validations.scheme.owning_organisation.does_not_own_stock") + errors.add :parent_organisation_id, I18n.t("validations.organisation.housing_provider.does_not_own_stock") end end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 4f6f6c5b5..ee3ad6b25 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -116,6 +116,13 @@ en: organisation: name_missing: "Enter the name of the organisation" provider_type_missing: "Select the organisation type" + housing_provider: + blank: "You must choose a housing provider" + already_added: "You have already added this housing provider" + does_not_own_stock: "Enter an organisation that owns housing stock" + managing_agent: + blank: "You must choose a managing agent" + already_added: "You have already added this managing agent" not_answered: "You must answer %{question}" other_field_missing: "If %{main_field_label} is other then %{other_field_label} must be provided"