Users of my application are asked for their country and postal code. I want to use the postal codes as a key in data store. Because the postal codes are entered by the user they can have been entered in different forms. For example a Canadian user might have entered:
- A1A 1A1
- a1a 1a1
- A1A1A1
- a1A 1A1
- etc...
Now I can make a normalization function for Canadian postal codes that chooses one canonical form (for example, all uppercase without spaces) and convert the postal codes to the canonical form before saving it as a DB key.
But, that only covers Canada. I don't want to reinvent the wheel. Is there a library or API out there that can normalize (and possibly validate) postal codes for all (or many) countries?
Thanks!