Re: Validation class comments
| From: | Tomas V.V.Cox | Date: | Wed, 29 May 2002 06:59:30 +0000 |
| Subject: | Re: Validation class comments | ||
| References: | 1 2 3 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-6561@lists.php.net to get a copy of this message | ||
Pierre-Alain Joye wrote:
>
> On 28 May 2002 20:55:34 +0200
> "Tomas V.V.Cox" <cox@idecnet.com> wrote:
>
> > I'm talking about performance not easy of use :-)
> As usual, hard to make compromises between modularity and performances.
Just including one class is a good compromise for me :). At least for
more common operations.
> Basically, the core validation should contain the following :
>
> Basic types :
> string
> email (optional MX check (calls network container) )
implemented
> reserved words ( must have words[] )
can take place
> regexp
> min length
> max length
see my Validate::string() idea. I guess is enough flexible and easy to
use, no?
> commonly used algos ( string algo stuffs like a std checksum with key
> incuded )
if they are "common" of course.
> url's
will add it
> others ?
>
> numeric
> interval [min,max]
> precision (decimal)
I'll extend the Validate::number() to support this two cases too
> commonly used algos (luhn, ... )
feel free to add them :)
> And the 2nd level we would find :) :
> extended numeric :
> number localized ( "1'000'000.23","1 000 000.23",
> "1,000,000.23",...)
> currencies ("CHF 10'000,23") ( uses number localized and string)
>
> extended string :
> rarely used algos
>
> network
> DNS ( MX, www)
> others ?
No problem on adding them if they go on other files.
> Complex types
> dates base ( std numeric "4/23/2002" "23.4.2002",...)
> extended dates ( ISO, human readable )
Data validation will be supported, see the Validate::date() I proposed.
> Nth Level
> XML:
> A way to define complex rules with a xml, something like powerforms
> rules definition. To control the validation flows (an item makes another
> mandatory,...).
<maintainer>
<handle>pa</handle>
<name>Pierre-Alain Joye</name>
<role>developer</role>
</maintainer>
:-)
> Maybe it will be usefull to get a convert tool used by Validate or any
> others pear modules. Validate may certainly be used to validate data
> from forms ( :) ), and certainly during an import csv file ( callback by
> file::csv b.e. ) or from a soap server to check client data. This will
> create the need of en/decode functionnalities.
That will be covered by the Validate::multiple(). My idea for it is:
Validate::multiple(array &$data, array $val_type, bool $strict)
$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)
For example:
$opts = array(
'name' => array('string', VAL_NAME, 1, 50),
'address => array('string', VAL_STREET, 1, 100),
'age' => array('number', false, 1, 120)
);
$res = Validate::multiple($_POST, $opts, true)
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.
I guess this is enough flexible to be able to plug it everywhere you
think.
> Anyway, we should start the core :). A lot of work has been done in
> QuickForm, OOH_Forms, SOAP, we can try to get back the code ?
I actually have started: pear/Validate/Validate.php :-) Feel free to
review it.
> just ideas,
Thanks for the feedback, nice ideas.
Tomas V.V.Cox