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_US » Bug #6898

Change if empty() then true behavior of Validate_US::phoneNumber()

Details

Request #6898Change if empty() then true behavior of Validate_US::phoneNumber()
Submitted2006-02-22 23:47 UTC
Fromnhyde at bigdrift dot com
Assigneddavidc
StatusClosed
PackageValidate_US
PHP Version4.4.1
OSRH 9
Roadmaps0.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!