Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.6.2

Bug #9084 Validate_ES::dni wrong use of function arguments
Submitted: 2006-10-18 22:09 UTC
From: jabi at irontec dot com Assigned: doconnor
Status: Closed Package: Validate_ES (version 0.5.1)
PHP Version: 4.4.4 OS: GNU/Linux
Roadmaps: (Not assigned)    
Subscription  


 [2006-10-18 22:09 UTC] jabi at irontec dot com (Javier Infante)
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)

Comments

 [2006-10-18 23:09 UTC] jabi at irontec dot com
The bug is in the Validate_ES class, not in Validate
 [2008-05-24 07:42 UTC] doconnor (Daniel O'Connor)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. Fixed as part of Bug #4660