[openaddresses] adding country-specific validators and doing no validation on house numbers in Colombia
This commit is contained in:
@@ -149,6 +149,10 @@ class OpenAddressesFormatter(object):
|
||||
return True
|
||||
return cls.validate_house_number(house_number)
|
||||
|
||||
@classmethod
|
||||
def validate_colombian_house_number(cls, house_number):
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
def validate_chinese_house_number(cls, house_number):
|
||||
if not house_number:
|
||||
@@ -180,6 +184,12 @@ class OpenAddressesFormatter(object):
|
||||
}
|
||||
}
|
||||
|
||||
country_validators = {
|
||||
Countries.COLOMBIA: {
|
||||
AddressFormatter.HOUSE_NUMBER: validators.validate_colombian_house_number
|
||||
}
|
||||
}
|
||||
|
||||
chinese_annex_regex = re.compile(u'([\d]+)(?![号栋])', re.U)
|
||||
|
||||
@classmethod
|
||||
@@ -357,7 +367,7 @@ class OpenAddressesFormatter(object):
|
||||
|
||||
value = value.strip(', -')
|
||||
|
||||
validator = self.language_validators.get(language, {}).get(key, self.component_validators.get(key, None))
|
||||
validator = self.country_validators.get(country_dir, {}).get(key, self.language_validators.get(language, {}).get(key, self.component_validators.get(key, None)))
|
||||
|
||||
if validator is not None and not validator(value):
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user