Validate_World
| From: | bertrand Gugger | Date: | Sat, 07 Apr 2007 13:50:18 +0000 |
| Subject: | Validate_World | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-46171@lists.php.net to get a copy of this message | ||
Hello,
It's an old idea I had as I entered the Validate & Co., a package able to call local validation methods on general world level.
So for example, you can use:
$ok = Validate_World::postalCode($nationCode, $value);
It's in http://cvs.php.net/viewvc.cgi/pear/Validate/Validate/World.php
I've put some weak validation default, case the nation or method does
not exist.
Anyway, implementer may
define('VALIDATE_WORLD_DEFAULT', 0); // please dont use false here
to get a "strong" validation.
Currently, 5 common methods are implemented
Any of them takes as first argument the nation code:
* Personal Identity Number , formerly mixed with ssn() :
function pin($nationCode, $ssn)* Social Security Number :
function ssn($nationCode, $ssn)* Postal Code
function postalCode($nationCode, $postalCode)* Region, as US state or french departement ...
function region($nationCode, $region)* Phone number
function phoneNumber($nationCode, $phoneNumber)For other common methods, check() is kept public, $args being an array starting with nation code:
function check($what, $args)e.g. $ok = Validate_World::check('passport', array('XX, $passportCode); The compat tables should be complete, every Validate_XX contributor is wellcome to check and correct them. Note that pin() Personal Identity Number and ssn() Social Security Number are now distinguished and maybe some stuff is wrong, e.g. lot of nations have a passport() validation which maybe a pin, please check accordingly. I'm also pleased to announce the very next introduction of Validate_IT Validate_RU :) Any comment wellcome -- toggg