hut-python-validators
Python data normalization and validation.
Language:
Private packages:
Overview
Python data normalization and validation.
Repository
- GitHub: https://github.com/Hut42/hut-python-validators
- Language: Python
- Created: 2025-06-22
- Last Updated: 2025-11-07
Latest Release
- Version: v0.5
- Published: 2025-11-07
Documentation
hut-python-validators
Python data normalization and validation for UK-specific formats.
This library provides utilities to normalize and validate common UK data formats including postcodes, vehicle registration numbers, and telephone numbers.
============ Installation
.. code-block:: bash
pip install hut-python-validators
======== Features
UK Postcodes
Normalize and validate UK postcodes according to the Royal Mail PAF format.
normalize_postcode
Normalizes a UK postcode by converting to uppercase, removing spaces, and optionally reformatting with a space before the last three characters.
.. code-block:: python
from hut_validators.postcodes import normalize_postcode
# Basic normalization (adds space)
normalize_postcode("ec1a1bb")
# Returns: 'EC1A 1BB'
# Without space
normalize_postcode("ec1a1bb", add_space=False)
# Returns: 'EC1A1BB'
# Handles existing spaces and whitespace
normalize_postcode(" EC1A 1BB ")
# Returns: 'EC1A 1BB'
**Parameters:**
* ``postcode`` (str): The postcode to normalize
* ``add_space`` (bool, optional): Whether to insert a space before the last three characters. Defaults to True.
*[Full documentation available in the repository README]*
## Usage
This library is used by 2 application(s):
- django-hut-python-validators - extensions to hut-python-validators to allow for usage in django.
- bikesure-affiliates - Bikesure Dealer Directory public frontend