Allow any postal code by default

Due to the way Madrid handled postal code validations (see issue 533),
by default we were requiring everyone to validate against the local
census *and* to specify valid postal codes.

This could be useful in some cases, but in other cases, the census
validation will be enough and there'll be no need to manually define the
valid postal codes. Besides, some CONSUL installations are used in
organizations or political parties where the postal code validation
doesn't make sense.
This commit is contained in:
Javi Martín
2021-11-14 16:46:05 +01:00
parent 35e0477e03
commit c2e95f6b86
6 changed files with 23 additions and 3 deletions

View File

@@ -177,7 +177,7 @@ class Setting < ApplicationRecord
"machine_learning.comments_summary": false,
"machine_learning.related_content": false,
"machine_learning.tags": false,
"postal_codes": "00001:99999",
"postal_codes": "",
"remote_census.general.endpoint": "",
"remote_census.request.method_name": "",
"remote_census.request.structure": "",

View File

@@ -104,6 +104,8 @@ class Verification::Residence
end
def valid_postal_code?
return true if Setting["postal_codes"].blank?
Setting["postal_codes"].split(",").any? do |code_or_range|
if code_or_range.include?(":")
Range.new(*code_or_range.split(":").map(&:strip)).include?(postal_code&.strip)