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_ES » Bug #9084

Validate_ES::dni wrong use of function arguments

Details

Submitted2006-10-18 22:09 UTC
Fromjabi at irontec dot com
Assigneddoconnor
StatusClosed
PackageValidate_ES
PHP Version4.4.4
OSGNU/Linux
Roadmaps(Not assigned)

Comments

[2006-10-18 22:09 UTC] jabi at irontec dot com

Description:
------------
The Validate::dni function has two conditionals which i think are wrong:

if (!Validate::string($number, VALIDATE_NUM, 8, 8)) {
return false;
}
if (!Validate::string($letra, VALIDATE_ALPHA)) {
return false;
}

The function will return false anyway thanks to the checks below those 2 conditions, but the sintax for the Validate::string method is not correctly written.

Test script:
---------------
They should be something like this:

if (!Validate::string($number, array('format'=>VALIDATE_NUM,'min_length'=>8,'max_length'=>8))) {
return false;
}

if (!Validate::string($letra, array("format"=>VALIDATE_ALPHA_UPPER))) {
return false;
}

or in case the character extraction is more like this:

$letra = strtoupper(substr($dni, -1)); // Line 59

if (!Validate::string($letra, array("format"=>VALIDATE_ALPHA))) {
return false;
}

This way the function will return false when they are suppoused to, and it may accept lower case letters (more user friendly in my opinion)

[2006-10-18 23:09 UTC] jabi at irontec dot com

The bug is in the Validate_ES class, not in Validate