From d32a7af439f3a1d5e050a7538be84c280c79b3dd Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Fri, 27 Jan 2023 11:55:23 +0000 Subject: [PATCH] feat: wip commit --- .../form/sales/questions/property_number_of_bedrooms.rb | 2 -- app/models/validations/sales/property_validations.rb | 8 ++++++++ config/locales/en.yml | 3 +-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/models/form/sales/questions/property_number_of_bedrooms.rb b/app/models/form/sales/questions/property_number_of_bedrooms.rb index e8ea674ea..7165921f5 100644 --- a/app/models/form/sales/questions/property_number_of_bedrooms.rb +++ b/app/models/form/sales/questions/property_number_of_bedrooms.rb @@ -7,7 +7,5 @@ class Form::Sales::Questions::PropertyNumberOfBedrooms < ::Form::Question @hint_text = "A bedsit has 1 bedroom" @type = "numeric" @width = 10 - @min = 1 - @max = 9 end end diff --git a/app/models/validations/sales/property_validations.rb b/app/models/validations/sales/property_validations.rb index 879e37ff1..2c9473b16 100644 --- a/app/models/validations/sales/property_validations.rb +++ b/app/models/validations/sales/property_validations.rb @@ -7,4 +7,12 @@ module Validations::Sales::PropertyValidations record.errors.add :ppostcode_full, I18n.t("validations.property.postcode.must_match_previous") end end + + def validate_bedroom_number(record) + return unless record.beds + + unless record.beds.between?(1, 9) + record.errors.add :beds, I18n.t("validations.property.beds.1_9") + end + end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 3dd612e8e..7bb70cbe4 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -195,6 +195,7 @@ en: beds: non_positive: "Number of bedrooms has to be greater than 0" over_max: "Number of bedrooms cannot be more than 12" + 1_9: "Bedroom number must be 1-9" postcode: must_match_previous: "Buyer's last accommodation and discounted ownership postcodes must match" @@ -423,8 +424,6 @@ en: Contract exchange date must be less than 1 year before completion date previous_property_beds: property_type_bedsit: "Bedsit bedroom maximum 1" - previous_property_type: - property_type_bedsit: "A bedsit can not have more than 1 bedroom" discounted_ownership_value: "Mortgage, deposit, and grant total must equal £%{value_with_discount}" soft_validations: