Cimpress-MCP / postal-codes-js

Provide postal code validation for javascript
Apache License 2.0
43 stars 36 forks source link

Fix typo in regex for GB postcodes #83

Open jmorgadosoares opened 4 months ago

jmorgadosoares commented 4 months ago

Corrected a missing dash in the regular expression used for postcode validation. The old regex failed to properly validate certain postcodes from the list of valid examples, despite the validate function working correctly.

Specifically, the postcodes "W1A 0AX" and "W1U 1BW" (without the redundant spaces) were not validated by the regex due to the missing dash.

image

It's probably due to an issue with the ValidationRegex.DOC on page 6 here https://www.gov.uk/government/uploads/system/uploads/attachment_data/file/488478/Bulk_Data_Transfer_-_additional_validation_valid_from_12_November_2015.pdf

When you copy the regex it fails to copy the dash as well

image