[openaddresses] Adding sin numero validator (sem numero in this case) for Portuguese
This commit is contained in:
@@ -37,6 +37,7 @@ not_applicable_regex = re.compile('^\s*n\.?\s*/?\s*a\.?\s*$', re.I)
|
|||||||
sin_numero_regex = re.compile('^\s*s\s\s*/\s*n\s*$')
|
sin_numero_regex = re.compile('^\s*s\s\s*/\s*n\s*$')
|
||||||
|
|
||||||
SPANISH = 'es'
|
SPANISH = 'es'
|
||||||
|
PORTUGUESE = 'pt'
|
||||||
|
|
||||||
|
|
||||||
class OpenAddressesFormatter(object):
|
class OpenAddressesFormatter(object):
|
||||||
@@ -115,7 +116,7 @@ class OpenAddressesFormatter(object):
|
|||||||
return house_number.strip() and is_numeric(house_number) and not all((c == '0' for c in house_number if c.isdigit()))
|
return house_number.strip() and is_numeric(house_number) and not all((c == '0' for c in house_number if c.isdigit()))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def validate_house_number_spanish(cls, house_number):
|
def validate_house_number_sin_numero(cls, house_number):
|
||||||
if sin_numero_regex.match(house_number):
|
if sin_numero_regex.match(house_number):
|
||||||
return True
|
return True
|
||||||
return cls.validate_house_number(house_number)
|
return cls.validate_house_number(house_number)
|
||||||
@@ -128,8 +129,11 @@ class OpenAddressesFormatter(object):
|
|||||||
|
|
||||||
language_validators = {
|
language_validators = {
|
||||||
SPANISH: {
|
SPANISH: {
|
||||||
AddressFormatter.HOUSE_NUMBER: validators.validate_house_number_spanish,
|
AddressFormatter.HOUSE_NUMBER: validators.validate_house_number_sin_numero,
|
||||||
},
|
},
|
||||||
|
PORTUGUESE: {
|
||||||
|
AddressFormatter.HOUSE_NUMBER: validators.validate_house_number_sin_numero,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_property(self, key, *configs):
|
def get_property(self, key, *configs):
|
||||||
|
|||||||
Reference in New Issue
Block a user