Ignore trailing spaces in postal codes verification

This way both administrators and regular citizens have a certain margin
of error when entering the postal codes.
This commit is contained in:
Javi Martín
2021-11-14 15:56:55 +01:00
parent 5cc10cbadf
commit 35e0477e03
2 changed files with 30 additions and 2 deletions

View File

@@ -106,9 +106,9 @@ class Verification::Residence
def valid_postal_code?
Setting["postal_codes"].split(",").any? do |code_or_range|
if code_or_range.include?(":")
Range.new(*code_or_range.split(":")).include?(postal_code)
Range.new(*code_or_range.split(":").map(&:strip)).include?(postal_code&.strip)
else
postal_code == code_or_range
postal_code&.strip == code_or_range.strip
end
end
end