Browse Source

feat: use old min/max bedrooms validations

CLDC-1790-sales-validation-content-updates
natdeanlewissoftwire 2 years ago
parent
commit
8452c9fab1
  1. 2
      app/models/form/sales/questions/property_number_of_bedrooms.rb
  2. 8
      app/models/validations/sales/property_validations.rb
  3. 1
      config/locales/en.yml
  4. 4
      spec/models/form/sales/questions/property_number_of_bedrooms_spec.rb

2
app/models/form/sales/questions/property_number_of_bedrooms.rb

@ -7,5 +7,7 @@ class Form::Sales::Questions::PropertyNumberOfBedrooms < ::Form::Question
@hint_text = "A bedsit has 1 bedroom"
@type = "numeric"
@width = 10
@min = 1
@max = 9
end
end

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

@ -7,12 +7,4 @@ 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

1
config/locales/en.yml

@ -195,7 +195,6 @@ 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"

4
spec/models/form/sales/questions/property_number_of_bedrooms_spec.rb

@ -36,10 +36,10 @@ RSpec.describe Form::Sales::Questions::PropertyNumberOfBedrooms, type: :model do
end
it "has the correct min" do
expect(question.min).to eq(nil)
expect(question.min).to eq(1)
end
it "has the correct max" do
expect(question.max).to eq(nil)
expect(question.max).to eq(9)
end
end

Loading…
Cancel
Save