PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Validate » Validate » Bug #4055

Patch for Validate::multiple() and CreditCard::number()

Details

Request #4055Patch for Validate::multiple() and CreditCard::number()
Submitted2005-04-04 17:30 UTC
Fromroehr at zilleon dot com
Assigneddufuz
StatusClosed
PackageValidate
PHP VersionIrrelevant
OSIrrelevant
Roadmaps(Not assigned)

Comments

[2005-04-04 17:30 UTC] roehr at zilleon dot com

Description:
------------
Hi,

I have created the following patches:

[1] Validate::multiple()
http://www.zilleon.de/PEAR/Validate/Validate.diff.txt
http://www.zilleon.de/PEAR/Validate/Validate.php.txt

This patch changes the resolving of the class/method name when using one of Validate's subpackages. Until now only the first two elements (e.g. us_ssn) were recognized. This made it impossible to use the CreditCard or IBAN classes because their call consists of three parts:
Finance_CreditCard_number
Finance_IBAN_validate

Now the last part is used as the method name and the rest makes up the class name. To use the CreditCard package within multiple you need to declare:
'type' => 'Finance_CreditCard_number'

Because I have only removed a limitation, BC should be guaranteed.

[2] Validate_Finance_CreditCard::number()
http://www.zilleon.de/PEAR/Validate/Finance/CreditCard.diff.txt

When calling this method via Validate::multiple() the options parameter $opt is passed to Validate_Finance_CreditCard::number() as an array. Because number() is checking for !is_null() it will always process this part of the method and thereby always return false. The patch changes the check to is_string().

[3] UnitTest for Validate::multiple()
http://www.zilleon.de/PEAR/Validate/tests/multiple.php.txt

Thanks for having a look at this!

Best regards, Torsten Roehr