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

Bug #16897 Validate fractional numbers less than 1
Submitted: 2009-12-10 16:28 UTC
From: davidsimpson Assigned:
Status: Open Package: Validate (version 0.8.3)
PHP Version: 5.2.5 OS: Windows and Solaris
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 47 - 6 = ?

 
 [2009-12-10 16:28 UTC] davidsimpson (David Simpson)
Description: ------------ Validation of decimal numbers such as ".5" fails, although "0.5" passes. As db engines (in our case Oracle) do not store the leading zero, we get validation failures using DB_DataObject in combination with Validate. Test script: --------------- $testval='-.5'; $test = Validate::number( $testval, array('decimal'=>'.')); var_dump($test); Replacing line 270 of Validate.php with the following two lines gives the expected result: $num_regex = $dec_regex == '' ? "|^[-+]?\s*[0-9]+\$|" : "/^[-+]?\s*(([0-9]+)([$decimal][0-9]+)?)|([$decimal][0-9]+)\$/"; if (!preg_match($num_regex, $number)) { Expected result: ---------------- bool(true) Actual result: -------------- bool(false)

Comments