Browse Source

Update error messages

pull/2763/head
Kat 9 months ago
parent
commit
c3ddae8e92
  1. 8
      app/models/validations/property_validations.rb
  2. 6
      app/models/validations/sales/property_validations.rb
  3. 20
      config/locales/validations/lettings/property_information.en.yml
  4. 13
      config/locales/validations/sales/property_information.en.yml
  5. 4
      spec/models/validations/property_validations_spec.rb
  6. 2
      spec/models/validations/sales/property_validations_spec.rb

8
app/models/validations/property_validations.rb

@ -59,14 +59,18 @@ module Validations::PropertyValidations
record.errors.add :uprn, I18n.t("validations.lettings.property.uprn.not_in_england") record.errors.add :uprn, I18n.t("validations.lettings.property.uprn.not_in_england")
record.errors.add :uprn_confirmation, I18n.t("validations.lettings.property.uprn_confirmation.not_in_england") record.errors.add :uprn_confirmation, I18n.t("validations.lettings.property.uprn_confirmation.not_in_england")
record.errors.add :uprn_selection, I18n.t("validations.lettings.property.uprn_selection.not_in_england") record.errors.add :uprn_selection, I18n.t("validations.lettings.property.uprn_selection.not_in_england")
record.errors.add :startdate, I18n.t("validations.lettings.property.startdate.not_in_england") if record.uprn.present?
record.errors.add :startdate, I18n.t("validations.lettings.property.startdate.address_not_in_england")
else
record.errors.add :startdate, I18n.t("validations.lettings.property.startdate.postcode_not_in_england")
end
elsif record.is_supported_housing? elsif record.is_supported_housing?
return unless record.location return unless record.location
return if record.location.location_code.in?(LocalAuthority.england.pluck(:code)) return if record.location.location_code.in?(LocalAuthority.england.pluck(:code))
record.errors.add :location_id, I18n.t("validations.lettings.property.location_id.not_in_england") record.errors.add :location_id, I18n.t("validations.lettings.property.location_id.not_in_england")
record.errors.add :scheme_id, I18n.t("validations.lettings.property.scheme_id.not_in_england") record.errors.add :scheme_id, I18n.t("validations.lettings.property.scheme_id.not_in_england")
record.errors.add :startdate, I18n.t("validations.lettings.property.startdate.not_in_england") record.errors.add :startdate, I18n.t("validations.lettings.property.startdate.location_not_in_england")
end end
end end
end end

6
app/models/validations/sales/property_validations.rb

@ -46,6 +46,10 @@ module Validations::Sales::PropertyValidations
record.errors.add :uprn, I18n.t("validations.sales.property_information.uprn.not_in_england") record.errors.add :uprn, I18n.t("validations.sales.property_information.uprn.not_in_england")
record.errors.add :uprn_confirmation, I18n.t("validations.sales.property_information.uprn_confirmation.not_in_england") record.errors.add :uprn_confirmation, I18n.t("validations.sales.property_information.uprn_confirmation.not_in_england")
record.errors.add :uprn_selection, I18n.t("validations.sales.property_information.uprn_selection.not_in_england") record.errors.add :uprn_selection, I18n.t("validations.sales.property_information.uprn_selection.not_in_england")
record.errors.add :saledate, I18n.t("validations.sales.property_information.saledate.not_in_england") if record.uprn.present?
record.errors.add :saledate, I18n.t("validations.sales.property_information.saledate.address_not_in_england")
else
record.errors.add :saledate, I18n.t("validations.sales.property_information.saledate.postcode_not_in_england")
end
end end
end end

20
config/locales/validations/lettings/property_information.en.yml

@ -4,7 +4,7 @@ en:
property: property:
postcode_full: postcode_full:
invalid: "Enter a postcode in the correct format, for example AA1 1AA." invalid: "Enter a postcode in the correct format, for example AA1 1AA."
not_in_england: "It looks like you have entered a postcode for a local authority outside of England - only submit Lettings forms for Lettings that occur in England" not_in_england: "It looks like you have entered a postcode outside of England - only submit Lettings forms for Lettings that occur in England"
rsnvac: rsnvac:
non_temp_accommodation: "Answer cannot be re-let to tenant who occupied the same property as temporary accommodation as this accommodation is not temporary." non_temp_accommodation: "Answer cannot be re-let to tenant who occupied the same property as temporary accommodation as this accommodation is not temporary."
referral_invalid: "Answer cannot be re-let to tenant who occupied the same property as temporary accommodation as a different source of referral for this letting." referral_invalid: "Answer cannot be re-let to tenant who occupied the same property as temporary accommodation as a different source of referral for this letting."
@ -19,16 +19,18 @@ en:
one_seven_bedroom_shared: "A shared house must have 1 to 7 bedrooms." one_seven_bedroom_shared: "A shared house must have 1 to 7 bedrooms."
uprn: uprn:
invalid: "UPRN must be 12 digits or less." invalid: "UPRN must be 12 digits or less."
not_in_england: "It looks like you have entered a UPRN for a local authority outside of England - only submit Lettings forms for Lettings that occur in England" not_in_england: "It looks like you have entered an address outside of England - only submit Lettings forms for Lettings that occur in England"
uprn_confirmation: uprn_confirmation:
not_in_england: "It looks like you have entered a UPRN for a local authority outside of England - only submit Lettings forms for Lettings that occur in England" not_in_england: "It looks like you have entered an address outside of England - only submit Lettings forms for Lettings that occur in England"
uprn_selection: uprn_selection:
not_in_england: "It looks like you have selected an address for a local authority outside of England - only submit Lettings forms for Lettings that occur in England" not_in_england: "It looks like you have entered an address outside of England - only submit Lettings forms for Lettings that occur in England"
la: la:
not_in_england: "It looks like you have entered a local authority outside of England - only submit Lettings forms for Lettings that occur in England" not_in_england: "It looks like you have entered an address outside of England - only submit Lettings forms for Lettings that occur in England"
scheme_id: scheme_id:
not_in_england: "It looks like you have selected a location with a local authority outside of England - only submit Lettings forms for Lettings that occur in England" not_in_england: "It looks like you have selected a location outside of England - only submit Lettings forms for Lettings that occur in England"
location_id: location_id:
not_in_england: "It looks like you have selected a location with a local authority outside of England - only submit Lettings forms for Lettings that occur in England" not_in_england: "“It looks like you have selected a location outside of England - only submit Lettings forms for Lettings that occur in England"
startdate: startdate:
not_in_england: "It looks like you have selected a local authority outside of England - only submit Lettings forms for Lettings that occur in England" postcode_not_in_england: "It looks like you have entered an address outside of England - only submit Lettings forms for Lettings that occur in England"
address_not_in_england: "It looks like you have entered a postcode outside of England - only submit Lettings forms for Lettings that occur in England"
location_not_in_england: "“It looks like you have selected a location outside of England - only submit Lettings forms for Lettings that occur in England"

13
config/locales/validations/sales/property_information.en.yml

@ -7,7 +7,7 @@ en:
joint_purchase: "Buyers’ last accommodation and discounted ownership postcodes must match." joint_purchase: "Buyers’ last accommodation and discounted ownership postcodes must match."
not_joint_purchase: "Buyer’s last accommodation and discounted ownership postcodes must match." not_joint_purchase: "Buyer’s last accommodation and discounted ownership postcodes must match."
invalid: "Enter a postcode in the correct format, for example AA1 1AA." invalid: "Enter a postcode in the correct format, for example AA1 1AA."
not_in_england: "It looks like you have entered a postcode for a local authority outside of England - only submit Sales forms for Sales that occur in England" not_in_england: "It looks like you have entered a postcode outside of England - only submit Lettings forms for Lettings that occur in England"
ppostcode_full: ppostcode_full:
postcode_must_match_previous: postcode_must_match_previous:
joint_purchase: "Buyers’ last accommodation and discounted ownership postcodes must match." joint_purchase: "Buyers’ last accommodation and discounted ownership postcodes must match."
@ -21,7 +21,7 @@ en:
joint_purchase: "Buyers’ last accommodation and discounted ownership postcodes must match." joint_purchase: "Buyers’ last accommodation and discounted ownership postcodes must match."
not_joint_purchase: "Buyer’s last accommodation and discounted ownership postcodes must match." not_joint_purchase: "Buyer’s last accommodation and discounted ownership postcodes must match."
invalid: "UPRN must be 12 digits or less." invalid: "UPRN must be 12 digits or less."
not_in_england: "It looks like you have entered a UPRN for a local authority outside of England - only submit Sales forms for Sales that occur in England" not_in_england: "It looks like you have entered an address outside of England - only submit Lettings forms for Lettings that occur in England"
beds: beds:
bedsits_have_max_one_bedroom: "Number of bedrooms must be 1 if the property is a bedsit." bedsits_have_max_one_bedroom: "Number of bedrooms must be 1 if the property is a bedsit."
proptype: proptype:
@ -29,10 +29,11 @@ en:
uprn_known: uprn_known:
invalid: "You must answer UPRN known?" invalid: "You must answer UPRN known?"
la: la:
not_in_england: "It looks like you have entered a local authority outside of England - only submit Sales forms for Sales that occur in England" not_in_england: "It looks like you have entered an address outside of England - only submit Lettings forms for Lettings that occur in England"
uprn_confirmation: uprn_confirmation:
not_in_england: "It looks like you have entered a UPRN for a local authority outside of England - only submit Sales forms for Sales that occur in England" not_in_england: "It looks like you have entered an address outside of England - only submit Lettings forms for Lettings that occur in England"
uprn_selection: uprn_selection:
not_in_england: "It looks like you have selected an address for a local authority outside of England - only submit Sales forms for Sales that occur in England" not_in_england: "It looks like you have entered an address outside of England - only submit Lettings forms for Lettings that occur in England"
saledate: saledate:
not_in_england: "It looks like you have selected a local authority outside of England - only submit Sales forms for Sales that occur in England" postcode_not_in_england: "It looks like you have entered an address outside of England - only submit Lettings forms for Lettings that occur in England"
address_not_in_england: "It looks like you have entered a postcode outside of England - only submit Lettings forms for Lettings that occur in England"

4
spec/models/validations/property_validations_spec.rb

@ -221,7 +221,7 @@ RSpec.describe Validations::PropertyValidations do
expect(log.errors["uprn"]).to include(I18n.t("validations.lettings.property.uprn.not_in_england")) expect(log.errors["uprn"]).to include(I18n.t("validations.lettings.property.uprn.not_in_england"))
expect(log.errors["uprn_confirmation"]).to include(I18n.t("validations.lettings.property.uprn_confirmation.not_in_england")) expect(log.errors["uprn_confirmation"]).to include(I18n.t("validations.lettings.property.uprn_confirmation.not_in_england"))
expect(log.errors["uprn_selection"]).to include(I18n.t("validations.lettings.property.uprn_selection.not_in_england")) expect(log.errors["uprn_selection"]).to include(I18n.t("validations.lettings.property.uprn_selection.not_in_england"))
expect(log.errors["startdate"]).to include(I18n.t("validations.lettings.property.startdate.not_in_england")) expect(log.errors["startdate"]).to include(I18n.t("validations.lettings.property.startdate.postcode_not_in_england"))
expect(log.errors["scheme_id"]).to be_empty expect(log.errors["scheme_id"]).to be_empty
expect(log.errors["location_id"]).to be_empty expect(log.errors["location_id"]).to be_empty
end end
@ -235,7 +235,7 @@ RSpec.describe Validations::PropertyValidations do
property_validator.validate_la_in_england(log) property_validator.validate_la_in_england(log)
expect(log.errors["scheme_id"]).to include(I18n.t("validations.lettings.property.scheme_id.not_in_england")) expect(log.errors["scheme_id"]).to include(I18n.t("validations.lettings.property.scheme_id.not_in_england"))
expect(log.errors["location_id"]).to include(I18n.t("validations.lettings.property.location_id.not_in_england")) expect(log.errors["location_id"]).to include(I18n.t("validations.lettings.property.location_id.not_in_england"))
expect(log.errors["startdate"]).to include(I18n.t("validations.lettings.property.startdate.not_in_england")) expect(log.errors["startdate"]).to include(I18n.t("validations.lettings.property.startdate.location_not_in_england"))
expect(log.errors["la"]).to be_empty expect(log.errors["la"]).to be_empty
expect(log.errors["postcode_full"]).to be_empty expect(log.errors["postcode_full"]).to be_empty
expect(log.errors["uprn"]).to be_empty expect(log.errors["uprn"]).to be_empty

2
spec/models/validations/sales/property_validations_spec.rb

@ -159,7 +159,7 @@ RSpec.describe Validations::Sales::PropertyValidations do
expect(log.errors["uprn"]).to include(I18n.t("validations.sales.property_information.uprn.not_in_england")) expect(log.errors["uprn"]).to include(I18n.t("validations.sales.property_information.uprn.not_in_england"))
expect(log.errors["uprn_confirmation"]).to include(I18n.t("validations.sales.property_information.uprn_confirmation.not_in_england")) expect(log.errors["uprn_confirmation"]).to include(I18n.t("validations.sales.property_information.uprn_confirmation.not_in_england"))
expect(log.errors["uprn_selection"]).to include(I18n.t("validations.sales.property_information.uprn_selection.not_in_england")) expect(log.errors["uprn_selection"]).to include(I18n.t("validations.sales.property_information.uprn_selection.not_in_england"))
expect(log.errors["saledate"]).to include(I18n.t("validations.sales.property_information.saledate.not_in_england")) expect(log.errors["saledate"]).to include(I18n.t("validations.sales.property_information.saledate.postcode_not_in_england"))
end end
end end

Loading…
Cancel
Save