Cimpress-MCP / postal-codes-js

Provide postal code validation for javascript
Apache License 2.0
43 stars 36 forks source link

Accept also the country name for the validation #35

Closed pedrofs closed 5 years ago

pedrofs commented 5 years ago

I would like to use it as follows:

postalCodes.validate('United Status', '12312');

Any concerns?

I can work on a PR.

ozankaya commented 5 years ago

Assuming you had a typo and want to use "United States", this seems to be error prone. That country is actually called "United States of America". It would be cumbersome to accept multiple versions of how a country is called. Country names change from time to time as well. For instance Former Yugoslavian Republic of Macedonia became North Macedonia recently.

ISO 3166-1 alpha-2 or alpha-3 country codes are the best for this task. Country name to ISO code conversion should be left to the application.