postcode-validator-uk

A simple UK postcode validator.


License
MIT
Install
pip install postcode-validator-uk==1.0.0

Documentation

postcode-validator-uk

Python CircleCI codecov

A simple UK postcode validator.

Implemented following these instructions: Wikipedia - Postcodes in the United Kingdom.

Install

postcode-validator-uk is available on PyPI:

$ pip install postcode-validator-uk

Usage

from postcode_validator_uk.validators import UKPostcode

postcode = UKPostcode('ec1a 1bb')
postcode.validate()

postcode.validated_postcode
# output
'EC1A 1BB'

postcode.raw_postcode
# output
'ec1a 1bb'

postcode.outward
# output
'EC1A'

postcode.inward
# output
'1BB'

postcode.area
# output
'EC'

postcode.district
# output
'1A'

postcode.sector
# output
'1'

postcode.unit
# output
'BB'

Running tests

$ poetry install
$ make test