-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(isPostalCode): Improve Dutch postal code regex #2271
fix(isPostalCode): Improve Dutch postal code regex #2271
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2271 +/- ##
=======================================
Coverage 99.95% 99.95%
=======================================
Files 107 107
Lines 2454 2454
Branches 619 619
=======================================
Hits 2453 2453
Partials 1 1 ☔ View full report in Codecov by Sentry. |
Is there maybe a link by PostNL (the national postal carrier) that explains these rules that we can use as a source? |
I checked their website, and I cannot find anything on there that explains it. There are plenty of other resources on the web that explain the rules. If you search "postcodekaart" (postal code map), you will see lots of maps. You can easily notice they never start with zero. The letter combinations "SA", "SD" and "SS" are avoided because of their associations with the Nazi occupation. |
Yeah, I've seen these changes in various other maps but I was hoping for some better source. I'll try to search for them in the coming days before approving this PR, since I do think these changes are correct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found more maps and lists, but couldn't really find a (semi-)official source unfortunately. Others suggest this regex (or similar ones) as well for Dutch postal codes
I came across an official source containing the same regular expression: https://tracking.postnl.nl/track-and-trace/api/trackAndTrace/countries |
Ah nice, and I see they have different countries as well. Could you add those in a separate PR? |
PostNL provides 20 regular expressions in total. I've compared the rest to those that we already have in validator.js, and ours are the same or more specific. |
Is there anything else that needs to be done before this pull request can be merged? Let me know if there's anything I can do to help. |
I have improved the regular expression for postal codes of the Netherlands. They cannot start with a zero, and they cannot contain "SA", "SD" and "SS".
More information: https://en.wikipedia.org/wiki/Postal_codes_in_the_Netherlands