Skip to content

Postcode Validation

Wikipedia cracks me up sometimes. I’m sat here at my desk, trying to knock together some C# code to quickly validate an entered string as being a UK postcode. Naturally I turned to this Wikipedia article for assistance, where I find this quip:

"Automatic validation of postcodes on the basis of pattern feasibility is therefore almost impossible to design, and the system contains no self-validating feature such as a check digit. Completely accurate validation is only possible by attempting to deliver mail to the address, and verifying with the recipient."

I think that’s what is known as a long-running transaction!!

Update – the C# code that I wrote to handle this issue is available here.

Published inFunTech
Copyright © Ian Fraser Nelson 2023