ukpostcodevalidator’s documentation!¶
This library validates the uk postal code based on the formating rules found on this article https://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom#Formatting
Usage¶
To validate the postal code for UK just invole the validate method on the Uk class as show below:
>>> from ukpostcodevalidator import validator
>>> validator.Uk.validate("AA9A 9AA")
Running Tests¶
To run tests for the project run the following command while inside the root directory ukpostcodevalidator
py.test tests.py
Api Documentation¶
-
class
ukpostcodevalidator.validator.
Uk
[source]¶ -
classmethod
check_inward_code
(inwardcode)[source]¶ Check the validity of postal code - inward code section.
- valid if :
- must start with a digit followed by two letters
- the letters don’t use CIKMOV.
:return True|False
-
classmethod
check_outward_code
(outwardcode)[source]¶ Check the validity of postal code - outward code section.
- code is a valid outward code if:
- has two and four characters long
- The letters QVX are not used in the first position.
- The letters IJZ are not used in the second position.
- The only letters to appear in the third position are ABCDEFGHJKPSTUW when the structure starts with A9A.
- The only letters to appear in the fourth position are ABEHMNPRVWXY when the structure starts with AA9A.
:return True|False
-
classmethod