Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Dutch (NL) postal code regex matches invalid values

Open
#208 2 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp

Research direction

Start with the Dutch postal-code validation data or entry point in libaddressinput and compare its regex with the issue's current and proposed patterns. Review the regex101 unit tests linked in the report, then verify that zero-prefixed codes and the SA, SD, and SS suffixes are rejected while valid Dutch codes remain accepted.

Written by the indexing model from the issue text.

Description

Hello there,

Following a discussion at work, I looked into a package used for postal code validation (axlon/postal-code-validation), which is seeding data from the Google Address Data Service (as pointed out in axlon/postal-code-validation#27).

After a short discussion, @wotta pointed out that the regex used is invalid. The regex (\d{4} ?[A-Z]{2}) allows the following invalid postal codes:

  • 0123 AB, which are invalid since all our postal codes start with 1-9.
  • 1111 SA, 1111 SD and 1111 SS, which are banned due to the SA, SD, and SS abbreviations which were used in the Second World War source.

A better regex for Dutch postal codes would be [1-9]\d{3} ?(?!SA|SD|SS)[A-Z]{2}, which explicitly excludes zero-based postal codes and invalid suffixes.

I made some tests on regex101.com (click on "Unit Tests" in the left sidebar).

Dominant language
C++
Stars
629
Forks
109
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from google/libaddressinput

All issues in google/libaddressinput

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.