Skip to content

sensei89v/postcodes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Task

Write a library that supports validating and formatting post codes for UK. The details of which postI l codes are valid and which are the parts they consist of can be found at https://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom#Formatting. The API that this library provides is your choice.

Building

python setup.py sdist

Installing

pip install . --upgrade

How to use

from postcodeworker import EnglandPostCodeWorker
worker = EnglandPostCodeWorker(False)
validated_post_code = worker.validate("le12 9SL")

Parameters of EnglandPostCodeWorker:

  • use_special_case: bool.

Available methods:

  • validate(post_code: str). Method return formatted post code if post_code is valid. If isn't the method raises exception ValidationError.

Run tests

Install pytest:

pip install pytest

Run tests:

python -m pytest .

Another similar libraries

  • postcode_validator_uk. Library doesn't work with special cases.
  • uk_postcode_validator. Library requires Internet connection.

What can improve

  • Add more detailed checking of areas and districts. For example: 'EC63' - available outward part, but there isn't this post code in the real world.
  • Add checking non-geographic post codes

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages