|
|
|
@ -22,10 +22,10 @@ module Validations::PropertyValidations
|
|
|
|
|
def validate_shared_housing_rooms(record) |
|
|
|
|
return unless record.unittype_gn |
|
|
|
|
|
|
|
|
|
if record.hhmemb == 1 && record.is_shared_housing? && |
|
|
|
|
!record.beds.to_i.between?(1, 3) && record.beds.present? |
|
|
|
|
if record.hhmemb == 1 && record.is_shared_housing? && !record.beds.to_i.between?(1, 3) && record.beds.present? |
|
|
|
|
record.errors.add :unittype_gn, I18n.t("validations.lettings.property.unittype_gn.one_three_bedroom_single_tenant_shared") |
|
|
|
|
record.errors.add :beds, :one_three_bedroom_single_tenant_shared, message: I18n.t("validations.lettings.property.beds.one_three_bedroom_single_tenant_shared") |
|
|
|
|
record.errors.add :hhmemb, I18n.t("validations.lettings.property.hhmemb.one_three_bedroom_single_tenant_shared") |
|
|
|
|
elsif record.is_shared_housing? && record.beds.present? && !record.beds.to_i.between?(1, 7) |
|
|
|
|
record.errors.add :unittype_gn, I18n.t("validations.lettings.property.unittype_gn.one_seven_bedroom_shared") |
|
|
|
|
record.errors.add :beds, I18n.t("validations.lettings.property.beds.one_seven_bedroom_shared") |
|
|
|
|