i18n Validations
Asked Answered
P

5

16

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:

  • Civil ID
  • Tax ID
  • SSN (Social Security Number)
  • BBAN (Basic Bank Account Number)
  • Fax, Phone and Mobile Numbers
  • Postal / Zip Codes
  • License Plates
  • Banknote Serial Numbers
  • and so on...

Is there any well hidden resource that I'm unaware of?

Planet answered 6/9, 2009 at 2:54 Comment(5)
I don't think SO is the right place to start such a project. You can use SO successfully to answer a specific question (e.g. "what is the format of license plates in France"), but it's not useful to perform comprehensive research.Coact
@Martin: while I agree with you I'll wait for some more feedback before deleting the question, I think it would be better to have a single question like this one and several answers for each country than hundreds of questions "who do I validate XXX for YYY".Planet
Even having thousands of employees, and a local branch, Google Checkout missed the correct Zip code for my town in Argentina. I was forced to use a wrong code to register.Miki
There are 2 questions in this thread. I agree the second one: using SO as a collaborative effort tool is not appropriate, but i'm very interested in the first question: "how do they do that?" So please don't delete it - edit it. ThanksLabonte
Seems like Google is reading this: i18napis.appspot.comPlanet
F
1

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.

Fergus answered 6/9, 2009 at 2:54 Comment(0)
C
1

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?

Copland answered 9/9, 2009 at 20:47 Comment(3)
I don't believe so, mainly because the validation methods for New Zealand (or any other country) are not coherent with other countries: Spain for instance only has DNI validation (civil ID) and Portugal (and many others) don't have any validation method. This is pretty much useless in a i18n environment IMO.Planet
Have you seen this? thomasweidner.com/flatpress/2009/09/19/zend_validate_postcodeCopland
@Steve: That's very interesting, how can I have a peek into the code?Planet
C
0

Perhaps from http://www.geonames.org/ they have a wonderful api too

Crowley answered 6/9, 2009 at 2:54 Comment(0)
L
0

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

Leptophyllous answered 6/9, 2009 at 2:54 Comment(2)
That is exactly the point, I'm from Portugal and I can write a pretty good set of validation methods for my country but I don't know a thing about Spain for instance. Wikipedia is good, and I've done some nice work researching there but there is a lot missing.Planet
yeah .. but you can always ask some random person online .. right .. forums , stackoverflow .. etc .. it takes just about 2 braincells to figure it out :PLeptophyllous
F
0

Wikipedia collects license plate information, by country. Likewise for postal codes.

Fredela answered 6/9, 2009 at 5:1 Comment(1)
There is a lot more to validation than just license plates and postal codes, nonetheless UPU has much better resources (upu.int/post_code/en/…) on postal code formats. Regarding the Wikipedia entry on license plates is very limited (only single pictures avaliable for 30 countries or so).Planet

© 2022 - 2024 — McMap. All rights reserved.