4 ms·
Even in North America, you shouldn't treat ZIP/postal codes as numbers. The US added 4 digits 30-ish years ago (ZIP+4) and they're separated with a dash. You c
by chiph 5y ago
Even in North America, you shouldn't treat ZIP/postal codes as numbers. The US added 4 digits 30-ish years ago (ZIP+4) and they're separated with a dash. You could store them as separate numbers [0] and rely on the presentation code to add the dash. But since Canada has alphanumeric postal codes (Mexico uses numbers), you're better off treating them as a string field.
The US used to prefix phone numbers with letters (like MElrose 1-2345) as an aide-mémoire during the transition to 8 digits with area codes. And you'll still see businesses advertising with letters in place of digits (like 800-GOT-JUNK which is a junk removal firm) but they never get entered into phone number fields like that. The best reason to have phone numbers as text though, is the digit groupings [1]. In North America, it's 3-3-4 but other countries group their numbers differently to help people remember them. So allowing users to enter numbers in their format you're making it easy for them.
[0] The main reason to do this is if you're in the business of sending out mailings. The US postal service gives discounts if you sort and bundle by ZIP code, and mixed ZIP and ZIP+4 values would make that hard.
[1] https://en.wikipedia.org/wiki/Chunking_(psychology) https://en.wikipedia.org/wiki/Chunking_(psychology)