[RFC] Validation class proposal
| From: | Tomas V.V.Cox | Date: | Wed, 22 May 2002 22:16:10 +0000 |
| Subject: | [RFC] Validation class proposal | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-6346@lists.php.net to get a copy of this message | ||
Let's stop wasting time talking and go to code something :-) My quick
proposal (sorry if I'm too cursory):
Dir structure
-------------
pear/Validate
Validate.php
pear/Validate/I18N/
ES.php
DE.php
FR.php
Validate.php
------------
Statics methods, easy syntax, return bool and all common validation
routines inside, even if it gets a little long. Something like:
// 0-9
define(NUM_NATURAL, 1);
// a-Z
define(ALPHA, 2);
// a-Z + áé..
define(EALPHA, 4);
// \s*
define(SPACE, 8);
define(DECIMAL, 16);
class Validate
{
function email($email, $domain_check=false)
function string($str, NUM+ALPHA, $lenght_check=false)
function creditCard($no)
// process an array (mostly for $_POST, $_GET) in the form:
// 0 => array($val, $options)
// where $options=>array(method, args, nullable)
function batch($array)
function date($date, $format, $range)
function youCanBeHere()
}
I18N/ES.php
---------------
class ValidateES
{
// Spanish Identity card validation
function dni($str)
}
Tomas V.V.Cox