Module: Validations::PropertyValidations
- Defined in:
- property_validations.rb
Constant Summary collapse
- REFERRAL_INVALID_TMP =
Validations methods need to be called ‘validate_<page_name>’ to run on model save or ‘validate_’ to run on submit as well
[8, 10, 12, 13, 14, 15].freeze
Instance Method Summary collapse
- #validate_rsnvac(record) ⇒ Object
- #validate_shared_housing_rooms(record) ⇒ Object
- #validate_unitletas(record) ⇒ Object
- #validate_uprn(record) ⇒ Object
Instance Method Details
#validate_rsnvac(record) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'property_validations.rb', line 6 def validate_rsnvac(record) if !record. && record.has_first_let_vacancy_reason? record.errors.add :rsnvac, I18n.t("validations.property.rsnvac.first_let_not_social") end if record. && record.rsnvac.present? && !record.has_first_let_vacancy_reason? record.errors.add :rsnvac, I18n.t("validations.property.rsnvac.first_let_social") end if record.is_relet_to_temp_tenant? && !record.previous_tenancy_was_temporary? record.errors.add :rsnvac, I18n.t("validations.property.rsnvac.non_temp_accommodation") end if record.is_relet_to_temp_tenant? && REFERRAL_INVALID_TMP.include?(record.referral) record.errors.add :rsnvac, I18n.t("validations.property.rsnvac.referral_invalid") record.errors.add :referral, :referral_invalid, message: I18n.t("validations.household.referral.rsnvac_non_temp") end if record.renewal.present? && record.renewal.zero? && record.rsnvac == 14 record.errors.add :rsnvac, I18n.t("validations.property.rsnvac.not_a_renewal") end end |
#validate_shared_housing_rooms(record) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'property_validations.rb', line 35 def validate_shared_housing_rooms(record) unless record.unittype_gn.nil? if record.is_bedsit? && record.beds != 1 && record.beds.present? && !record.form.start_year_after_2024? record.errors.add :unittype_gn, I18n.t("validations.property.unittype_gn.one_bedroom_bedsit") record.errors.add :beds, I18n.t("validations.property.unittype_gn.one_bedroom_bedsit") end 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.property.unittype_gn.one_three_bedroom_single_tenant_shared") record.errors.add :beds, :one_three_bedroom_single_tenant_shared, message: I18n.t("validations.property.unittype_gn.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.property.unittype_gn.one_seven_bedroom_shared") record.errors.add :beds, I18n.t("validations.property.unittype_gn.one_seven_bedroom_shared") end end end |
#validate_unitletas(record) ⇒ Object
29 30 31 32 33 |
# File 'property_validations.rb', line 29 def validate_unitletas(record) if record. && record.unitletas.present? record.errors.add :unitletas, I18n.t("validations.property.rsnvac.previous_let_social") end end |
#validate_uprn(record) ⇒ Object
53 54 55 56 57 58 59 |
# File 'property_validations.rb', line 53 def validate_uprn(record) return unless record.uprn return if record.uprn.match?(/^[0-9]{1,12}$/) record.errors.add :uprn, I18n.t("validations.property.uprn.invalid") end |