Browse Source

switched to between for range

pull/70/head
magicmilo 3 years ago
parent
commit
31b594d51c
  1. 4
      app/models/case_log.rb

4
app/models/case_log.rb

@ -119,13 +119,13 @@ class CaseLogValidator < ActiveModel::Validator
unless record.household_number_of_other_members.nil?
if record.household_number_of_other_members > 0
if record.property_unit_type.include?("Shared") && (record.property_number_of_bedrooms.to_i == 0 || record.property_number_of_bedrooms.to_i > 7)
if record.property_unit_type.include?("Shared") && !record.property_number_of_bedrooms.to_i.between?(1, 7)
record.errors.add :property_unit_type, "A shared house must have 1 to 7 bedrooms"
end
end
end
if record.property_unit_type.include?("Shared") && (record.property_number_of_bedrooms.to_i == 0 || record.property_number_of_bedrooms.to_i > 3)
if record.property_unit_type.include?("Shared") && !record.property_number_of_bedrooms.to_i.between?(1, 3)
record.errors.add :property_unit_type, "A shared house with less than two tenants must have 1 to 3 bedrooms"
end
end

Loading…
Cancel
Save