Browse Source

CLDC-3227: Allow neighbouring non-alphabet characters in soft validation check

pull/2236/head
Rachael Booth 2 years ago
parent
commit
1ca819e016
  1. 2
      app/models/validations/soft_validations.rb
  2. 6
      spec/models/validations/soft_validations_spec.rb

2
app/models/validations/soft_validations.rb

@ -164,7 +164,7 @@ module Validations::SoftValidations
].freeze ].freeze
def reasonother_might_be_existing_category? def reasonother_might_be_existing_category?
Regexp.union(PHRASES_LIKELY_TO_INDICATE_EXISTING_REASON_CATEGORY.map { |phrase| Regexp.new("\\b#{phrase}\\b", Regexp::IGNORECASE) }).match?(reasonother) Regexp.union(PHRASES_LIKELY_TO_INDICATE_EXISTING_REASON_CATEGORY.map { |phrase| Regexp.new("\\b[^[:alpha]]*#{phrase}[^[:alpha:]]*\\b", Regexp::IGNORECASE) }).match?(reasonother)
end end
private private

6
spec/models/validations/soft_validations_spec.rb

@ -1048,5 +1048,11 @@ RSpec.describe Validations::SoftValidations do
expect(record).not_to be_reasonother_might_be_existing_category expect(record).not_to be_reasonother_might_be_existing_category
end end
it "ignores neighbouring non-alphabet for matching" do
record.reasonother = "1Domestic abuse."
expect(record).to be_reasonother_might_be_existing_category
end
end end
end end

Loading…
Cancel
Save