hut-python-validators

Python data normalization and validation.

Overview

Python data normalization and validation.

Repository

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):

Last modified February 5, 2026: Adds proposal summary (2c393ca)