diff --git a/app/models/validations/household_validations.rb b/app/models/validations/household_validations.rb index a213f6844..05b496ebf 100644 --- a/app/models/validations/household_validations.rb +++ b/app/models/validations/household_validations.rb @@ -9,6 +9,16 @@ module Validations::HouseholdValidations end end + PHRASES_INDICATING_HOMELESSNESS = [ + "Homeless", + "Homelessness", + "Temporary accommodation", + "Temp accommodation", + "TA", + "Sleeping rough", + "Rough sleeping", + ].freeze + def validate_reason_for_leaving_last_settled_home(record) if record.reason == 32 && record.underoccupation_benefitcap != 4 record.errors.add :underoccupation_benefitcap, I18n.t("validations.household.underoccupation_benefitcap.dont_know_required") @@ -20,6 +30,12 @@ module Validations::HouseholdValidations record.errors.add :referral, I18n.t("validations.household.referral.reason_permanently_decanted") record.errors.add :reason, I18n.t("validations.household.reason.not_internal_transfer") end + + return unless record.form.start_year_after_2024? + + if record.reason == 20 && Regexp.union(PHRASES_INDICATING_HOMELESSNESS.map { |phrase| Regexp.new("\\A\\s*#{phrase}\\s*\\Z", Regexp::IGNORECASE) }).match?(record.reasonother) + record.errors.add :reason, I18n.t("validations.household.reason.other_not_settled") + end end def validate_armed_forces(record) diff --git a/config/locales/en.yml b/config/locales/en.yml index 6f0e6d642..5b34af84a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -541,6 +541,7 @@ en: reason: not_internal_transfer: "Answer cannot be ‘permanently decanted from another property owned by this landlord’ as you told us the source of referral for this tenancy was not an internal transfer" renewal_reason_needed: 'The reason for leaving must be "End of assured shorthold tenancy - no fault" or "End of fixed term tenancy - no fault" if the letting is a renewal' + other_not_settled: "Please give the reason for the tenant leaving their last settled home. This is where they were living before they became homeless, were living in temporary accommodation or sleeping rough" condition_effects: no_choices: "You cannot answer this question as you told us nobody in the household has a physical or mental health condition (or other illness) expected to last 12 months or more" postcode: