Re: Validate package API proposal
| From: | Pierre-Alain Joye | Date: | Mon, 17 Feb 2003 01:57:42 +0000 |
| Subject: | Re: Validate package API proposal | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-13397@lists.php.net to get a copy of this message | ||
On Sun, 16 Feb 2003 21:03:14 +0100
Bertrand Mansion <bmansion@mamasam.com> wrote:
> I mean you could also pass an array as parameter, like this:
> $rib = array('aCodeBanque' => 12,
> 'aCodeGuichet' => 131,
> 'aNoCompte' => 43,
> 'aKey' => 12);
> $validate = Validate_FR::rib($rib);
That works already.
> When multiple values need to be passed, you could use an array and
> when the method only needs one, you could use a scalar. Same goes for
> options.
Actually, everything can be passed in the same array, separates them
sounds good, i.e. default options for your app.
> I just looked at this method. It seems you MUST pass it an array, this
> will be a problem if I just want to validate a scalar like for
> instance an email.
Not exactly, you pass the value as it is. Pair key/value equals to
argumentname/value.
> Actually, no. I see two possible solutions. The first one would be to
> rewrite each methods while they are not too many so that they only
> accept 2 parameters (which is IMO enough for validation).
Hmmmm, I cannot say now 2 args is enough for a validation in any cases.
But we can take 2 args maximum, one for the data to check, one for the
options. If the datas and/or the options are superior to 1, then it will
be an array. Does that sound good to you (or anyone else :) ) ?
> The second one would be to write an abstraction method that will call
> the right method in the right package. With this solution, you will
> need to pass the country and the validation method name into your
> options array.
hmm, I hate abstract for this purpose, efficient is the word to keep in
mind here :)
> Let me know if you think this is feasible and if you need help with
> this. Thanks,
I need help for tests of every validation, and add validation functions
:)
I give a try tonite for the 1st solution and commit it, let me down asap
if that's good to you (again you==userbase :) ).
hth
pierre