Country-specific validation helpers, ported from Django Localflavor
Project description
localflavor
This package is a derivative of django-localflavor and a work in progress. This package does not depend on Django, and currently only contains postal codes validators, lists of country states and provinces and calling (dial in) codes.
Installation
pip install localflavor
Example usage
Postal code validation
>>> from localflavor.generic.validators import validate_country_postcode
>>> validate_country_postcode('1000AA', 'NL')
'1000 AA'
>>> validate_country_postcode('0888', 'US')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "../localflavor/generic/validators.py", line 453, in validate_country_postcode
return validator.clean(value)
File "../localflavor/base.py", line 71, in clean
value = super(RegexValidator, self).clean(value)
File "../localflavor/base.py", line 48, in clean
raise ValidationError(self.error_messages['invalid'])
localflavor.exceptions.ValidationError: Enter a valid ZIP code in the format XXXXX or XXXXX-XXXX.
Calling codes
>>> from localflavor.generic.countries.calling_codes import CALLING_CODES
>>> CALLING_CODES.get('US')
'+1'
>>> CALLING_CODES.get('RU')
'+7'
>>> CALLING_CODES.get('NL')
'+31'
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file localflavor-1.9.tar.gz.
File metadata
- Download URL: localflavor-1.9.tar.gz
- Upload date:
- Size: 79.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.6.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b051be69c778d02754be4a1c447d73107d80330e261e2eb77e17780e41e49272
|
|
| MD5 |
def11dd067028fa86d03e0b089bdbb7f
|
|
| BLAKE2b-256 |
631267fa0d311578aa90d4ba60bf8a567cc8b375b728589120a8a9e9aadc7048
|
File details
Details for the file localflavor-1.9-py3-none-any.whl.
File metadata
- Download URL: localflavor-1.9-py3-none-any.whl
- Upload date:
- Size: 123.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.6.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02820a541d5fd0317265b7bacbc6a30a19492decc97205620545e4ae8eb8689c
|
|
| MD5 |
f0a17ea42f71609d3b2a104da626b54b
|
|
| BLAKE2b-256 |
64b335a6dfefcf4dd005c356dbdc783afbfa2d3d89441c3b4894ce593fd70b7d
|