Skip to content
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

Merged

Conversation

RobinvanderVliet
Copy link
Contributor

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

@codecov
Copy link

codecov bot commented Aug 21, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.95%. Comparing base (b958bd7) to head (f0856e7).
Report is 2 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

@WikiRik
Copy link
Member

WikiRik commented Aug 21, 2023

Is there maybe a link by PostNL (the national postal carrier) that explains these rules that we can use as a source?

@RobinvanderVliet
Copy link
Contributor Author

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.

@WikiRik
Copy link
Member

WikiRik commented Aug 21, 2023

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

Copy link
Member

@WikiRik WikiRik left a 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

@RobinvanderVliet
Copy link
Contributor Author

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

Dutch postal code regular experssion

@WikiRik
Copy link
Member

WikiRik commented Dec 3, 2023

Ah nice, and I see they have different countries as well. Could you add those in a separate PR?

@RobinvanderVliet
Copy link
Contributor Author

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.

@RobinvanderVliet
Copy link
Contributor Author

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.

@profnandaa profnandaa merged commit edb6b1c into validatorjs:master Apr 25, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants