#3227·faker

UK Postcode. Better / more legiible validations

Author: luke-hillCreated Mar 10, 2026Updated Mar 19, 2026
Labels🐞 Issue: Bug

Describe the bug

UK Postcode regex isn't strictly speaking true. I am posting this to see if there is appetite / willingness to accept PRs that split out some of the complex regex

To Reproduce

The Generator produced the following invalid postcode. "Y0P 4AX"

Expected behavior

There is a good amount of validation. I would also prefer it if we went down the phone number route of wildcard / less variable stuff. As it's then more legible

Additional context

There are six authorized formats (A=Alpha, N=Numeric): Taken from Market Research and UK Gov

AN NAA (e.g., M1 1AA)
ANN NAA (e.g., M60 1NW)
AAN NAA (e.g., CR2 6XH)
AANN NAA (e.g., DN55 1PT)
ANA NAA (e.g., W1A 1HQ)
AANA NAA (e.g., EC1A 1BB)

However, these can further be granularised.