Reputation: 154613
Think Global, Act Local
That's what they tell you, however during all my time as I developer I've always seen big companies like Google, Microsoft, Oracle and so do validations in a localized manner: they know which country I'm from so they will try to validate my phone number, postal code and other details such as bank account numbers with the proper validation methods for my country. Yesterday I signed up for Google checkout and they even showed me some examples of postal code formats in my country!
So my question is, how do they do this? I know that they have thousands of employees but I find it hard to believe that they all had to reinvent the well. There are countless validations methods for the US but what about the rest of the world? I've not yet seen a single open source decent library (apart from a very incomplete and outdated PEAR attempt) to perform validations on various common aspects of countries such as:
Is there any well hidden resource that I'm unaware of?
Upvotes: 16
Views: 1500
Reputation: 240
Perhaps from http://www.geonames.org/ they have a wonderful api too
Upvotes: 0
Reputation: 8563
There's a huge difference between simple and full validation. It is often impossible to standardize validation fully across locales, here are a couple of examples:
CivilID/SSN etc. numbers can allow/disallow substitute values (system specific), foreign values, historic values etc. We have 2 different validation systems in one of our applications for the same field, depending on context, and other IT systems may have other validation systems.
ZIP code validation may require access to a list of valid values, which is something you need to subscribe to. In many countries, this subscription is not automated, and because of copyright rules, it is not trivial to redistribute.
Phone numbers have a similar problem. Do you allow expensive numbers, mobile phone numbers? How do you detect them?
You may argue that a simple validation is possible in most cases - but for simple validation, it is often easier to use pattern matching and to let the local department in each market define the valid patterns.
There is also a problem with the software service contract. If you buy software and want to use it for 5 years, then it is vital that you can change the validation rules, if something changes. I have experienced 4 changes of the phone number system in my country that affected simple validation like "number of digits" and "what can the first digit be".
Therefore, the best solution is to have a centralized database of locale-specific patterns, and to allow the administrators to modify the validation patterns.
Upvotes: 1
Reputation: 2852
Well , i think all it takes is one programmer from that country and a couple of days for reasearch & write the validations .. nothing special .. + there is tons of info in wikipedia
Upvotes: 0
Reputation: 3649
The PEAR one is not too bad. For example, the validator for New Zealand has all kinds of useful stuff like postal codes, IRD numbers, telephone numbers, bank account numbers http://pear.php.net/manual/en/package.validate.validate-nz.php
Its still in Alpha, but covers quite a few countries. Might be worth reconsidering?
Upvotes: 1
Reputation: 127517
Wikipedia collects license plate information, by country. Likewise for postal codes.
Upvotes: 0