
Have been looking into how to validate Danish postal codes and a simple regex is not enough, it can be used as a pre-check before actually validating the entire list of postal codes. Also note that the postal region of Denmark actually includes Greenland and Faroe Islands in the system, but of course different rates for shipping to them apply.
- Postal codes can start with 0
- They are between 3-4 characters long
- Only certain digit combinations are actually valid
1)
There are special postal code which is only 3 digit long, the following are a list of the once in Denmark
here is a list from the official source
Postnr Bynavn Gade Firma
0555 Scanning Data Scanning A/S, "Læs Ind"-service
0800 Høje Taastrup Girostrøget 1 BG-Bank A/S
0877 Københvn C Havneholmen 33 Aller Press (konkurrencer)
0892 Sjælland USF P Ufrankerede svarforsendelser
0893 Sjælland USF B Ufrankerede svarforsendelser
0897 eBrevsprækken (Post til scanning)
0899 Kommuneservice (Post til scanning)
0900 København C Københavns Postcenter + erhvervskunder
0910 København C Ufrankerede svarforsendelser
0917 Københavns Pakkecenter (Returpakker)
0918 Københavns Pakke BRC (Returpakker)
0919 Returprint BRC (Printerpatroner)
0929 København C Ufrankerede svarforsendelser
0999 København C Emil Holms Kanal 20 DR Byen
2)
All postal codes for Faroe Islands is only 3 digits
3)
Not all combinations of 3 or 4 digits are valid postal codes, there is only a smaller subset which should actually be considered valid.
It is possible to get a complete list (as html) at http://www.postdanmark.dk/da/Privat/Kundeservice/postnummerkort/Sider/Pr... (select "Alle typer" and hit the "vis print-venlig version" to get the list)
I am not sure I have the time to actually implement a fix for this right now, but hope to get around to it this week or the next (so hopefully I will have a patch incoming for it).
Comment | File | Size | Author |
---|---|---|---|
#2 | postal_code-danish-postal-code-2172413-2.patch | 738 bytes | lslinnet |
Comments
Comment #1
lslinnet CreditAttribution: lslinnet commentedFixed a chopped of paragraph.
Comment #2
lslinnet CreditAttribution: lslinnet commentedHave added a partial fix for the issue, it still does not completely verify the correctness of the entered postal codes.
Comment #3
jeremyclassic CreditAttribution: jeremyclassic commentedComment #5
jeremyclassic CreditAttribution: jeremyclassic commentedComment #6
jeremyclassic CreditAttribution: jeremyclassic commentedComment #7
jeremyclassic CreditAttribution: jeremyclassic commented