[Validate] multiple method

From: Date: Wed, 29 May 2002 12:41:48 +0000
Subject: [Validate] multiple method
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-6594@lists.php.net to get a copy of this message
hello, > Validate::multiple(array &$data, array $val_type, bool $strict) I m on it. > $data is a common associative array 'key' => 'value' and $val_type is > an assoc array too in the form: > 'key' => array('validation_type', $arg1, $arg2, $argN) easier to manage 'key'=>array('propertyN'=>valueN,....) or ? the array should be directly passed to the right validator function/container. New function definition : function string($string, $format = null, $min_lenght = 0, $max_lenght = 0) { if (is_array($string)){ $format = @$string['format']; // or isset($string['format']?$string['format']:"") b.e. ... } if ($format && !preg_match("|^[$format]*\$|s", $string)) { return false; } .... } Additionnaly, a core function mapping is necessary to know which type is internal or needed to be included ( as make in the sample date method ). As far we keep common validation methods inside the main class, we have to know it. var $core_methods = array('number','string','email','url'); any comments ? > The $strict arg will remove all the values from the $data param that > aren't in the $val_type array. Still in the TOTHINK is how to return a > clear answer of what and where the validation failed. Maybe not a good idea to remove data from the caller, in another way, it s an optionnal feature. > I guess this is enough flexible to be able to plug it everywhere you > think. How about returning a key=>[boolean]valid pa ps :sorry for the post on the cvs_list

« previous php.pear.dev (#6594) next »