Home » Validate » Validate_US » Bug #6898
Change if empty() then true behavior of Validate_US::phoneNumber()
Details
| Request #6898 | Change if empty() then true behavior of Validate_US::phoneNumber() |
|---|---|
| Submitted | 2006-02-22 23:47 UTC |
| From | nhyde at bigdrift dot com |
| Assigned | davidc |
| Status | Closed |
| Package | Validate_US |
| PHP Version | 4.4.1 |
| OS | RH 9 |
| Roadmaps | 0.5.3 |
Comments
[2006-02-22 23:47 UTC] nhyde at bigdrift dot com
Description:
------------
Remove the functionality of phoneNumber where if the $number is empty, ($number = ''), the validation method returns true.
Justification:
If we're validating a phoneNumber, the input should be a string or number with a min number of characters, as the regular expression expects. NULL is certainly not a valid phone number.
My thought being that if I'm attempting to actually validate an input, the value should at least resemble what I'm looking for.
Test script:
---------------
<?php
$aValues = array('ph'=>'');
$aResult = Validate::multiple($aValues,array('ph'=>array('type'=>'US_phonenumber'));
if (true == $aResult['ph'] && '' == $aValues['ph']) { echo 'Doh, empty string!'; } else { echo 'No number = Not a phone number.'; }
?>
Expected result:
----------------
No number = Not a phone number.
Due to lines 302-304 of US.php the method returns true.
Actual result:
--------------
Doh, empty string!