Browse Source

CLDC-1944: Rationalise validation messages and remove redundant validation error.#

pull/2280/head
Robert Sullivan 2 years ago
parent
commit
3535151aa7
  1. 2
      app/models/form/sales/pages/handover_date_check.rb
  2. 2
      app/models/form/sales/pages/sale_date_check.rb
  3. 2
      app/models/validations/sales/sale_information_validations.rb
  4. 7
      config/locales/en.yml
  5. 2
      spec/models/form/sales/pages/handover_date_check_spec.rb
  6. 2
      spec/models/form/sales/pages/sale_date_check_spec.rb

2
app/models/form/sales/pages/handover_date_check.rb

@ -6,7 +6,7 @@ class Form::Sales::Pages::HandoverDateCheck < ::Form::Page
{ "saledate_check" => 1, "hodate_3_years_or_more_saledate?" => true }]
@informative_text = {}
@title_text = {
"translation" => "validations.sale_information.hodate.must_be_less_than_3_years_from_saledate_soft",
"translation" => "soft_validations.hodate.must_be_less_than_3_years_from_saledate",
"arguments" => [],
}
end

2
app/models/form/sales/pages/sale_date_check.rb

@ -6,7 +6,7 @@ class Form::Sales::Pages::SaleDateCheck < ::Form::Page
{ "hodate_check" => 1, "hodate_3_years_or_more_saledate?" => true }]
@informative_text = {}
@title_text = {
"translation" => "validations.sale_information.saledate.must_be_less_than_3_years_from_hodate_soft",
"translation" => "soft_validations.saledate.must_be_less_than_3_years_from_hodate",
"arguments" => [],
}
end

2
app/models/validations/sales/sale_information_validations.rb

@ -13,7 +13,7 @@ module Validations::Sales::SaleInformationValidations
end
if record.saledate - record.hodate >= 3.years && record.form.start_year_after_2024?
record.errors.add :hodate, :over_a_year_from_saledate, message: I18n.t("validations.sale_information.hodate.must_be_less_than_3_years_from_saledate")
record.errors.add :hodate, message: I18n.t("validations.sale_information.hodate.must_be_less_than_3_years_from_saledate")
record.errors.add :saledate, I18n.t("validations.sale_information.saledate.must_be_less_than_3_years_from_hodate")
end
end

7
config/locales/en.yml

@ -606,7 +606,6 @@ en:
rent_to_buy: "Rent to Buy buyers should not have lived here before"
hodate:
must_be_before_saledate: "Practical completion or handover date must be before sale completion date"
must_be_less_than_3_years_from_saledate_soft: "You told us practical completion or handover date is more than 3 years before sale completion date"
must_be_less_than_3_years_from_saledate: "Practical completion or handover date must be less than 3 years before sale completion date"
exdate:
must_be_before_saledate: "Contract exchange date must be before sale completion date"
@ -615,7 +614,6 @@ en:
must_be_after_exdate: "Sale completion date must be after contract exchange date"
must_be_less_than_1_year_from_exdate: "Sale completion date must be less than 1 year after contract exchange date"
must_be_less_than_3_years_from_hodate: "Sale completion date must be less than 3 years after practical completion or handover date"
must_be_less_than_3_years_from_hodate_soft: "You told us sale completion date is more than 3 years after practical completion or handover date"
must_be_after_hodate: "Sale completion date must be after practical completion or handover date"
previous_property_type:
property_type_bedsit: "A bedsit cannot have more than 1 bedroom"
@ -750,6 +748,11 @@ Make sure these answers are correct."
informative_text: "The reason you have entered looks very similar to one of the existing response categories.
Please check the categories and select the appropriate one.
If the existing categories are not suitable, please confirm here to move onto the next question."
hodate:
must_be_less_than_3_years_from_saledate: "You told us practical completion or handover date is more than 3 years before sale completion date"
saledate:
must_be_less_than_3_years_from_hodate: "You told us sale completion date is more than 3 years after practical completion or handover date"
devise:
email:

2
spec/models/form/sales/pages/handover_date_check_spec.rb

@ -25,7 +25,7 @@ RSpec.describe Form::Sales::Pages::HandoverDateCheck, type: :model do
it "has the correct title_text" do
expect(page.title_text).to eq({
"translation" => "validations.sale_information.hodate.must_be_less_than_3_years_from_saledate_soft",
"translation" => "soft_validations.hodate.must_be_less_than_3_years_from_saledate",
"arguments" => [],
})
end

2
spec/models/form/sales/pages/sale_date_check_spec.rb

@ -25,7 +25,7 @@ RSpec.describe Form::Sales::Pages::SaleDateCheck, type: :model do
it "has the correct title_text" do
expect(page.title_text).to eq({
"translation" => "validations.sale_information.saledate.must_be_less_than_3_years_from_hodate_soft",
"translation" => "soft_validations.saledate.must_be_less_than_3_years_from_hodate",
"arguments" => [],
})
end

Loading…
Cancel
Save