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:
@@ -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": "",
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user