Browse Source

CLDC-3227: Update hard validation regex to ignore all non alphabet characters surrounding a match

pull/2236/head
Rachael Booth 2 years ago
parent
commit
427e138f83
  1. 2
      app/models/validations/household_validations.rb

2
app/models/validations/household_validations.rb

@ -33,7 +33,7 @@ module Validations::HouseholdValidations
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)
if record.reason == 20 && Regexp.union(PHRASES_INDICATING_HOMELESSNESS.map { |phrase| Regexp.new("\\A[^[:alpha:]]*#{phrase}[^[:alpha:]]*\\Z", Regexp::IGNORECASE) }).match?(record.reasonother)
record.errors.add :reason, I18n.t("validations.household.reason.other_not_settled")
end
end

Loading…
Cancel
Save