Skip to content

UK Postcode. Better / more legiible validations #3227

Description

@luke-hill

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions