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.

  1. Postal codes can start with 0
  2. They are between 3-4 characters long
  3. 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).

Comments

lslinnet’s picture

Issue summary: View changes

Fixed a chopped of paragraph.

lslinnet’s picture

Have added a partial fix for the issue, it still does not completely verify the correctness of the entered postal codes.

jeremyclassic’s picture

Status: Active » Reviewed & tested by the community

  • Commit bc2c589 on 7.x-1.x authored by lslinnet:
    Addresses issue #2172413: Danish postal codes incorrect.
    
jeremyclassic’s picture

Title: Danish postal codes (zip) are broken » Danish postal codes (zip) validation could be more exact.
jeremyclassic’s picture

Status: Reviewed & tested by the community » Fixed
jeremyclassic’s picture

Status: Fixed » Closed (fixed)