cvs: pear /Validate Validate.php
| From: | Tomas V.V.Cox | Date: | Wed, 29 May 2002 10:09:09 +0000 |
| Subject: | cvs: pear /Validate Validate.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-4244@lists.php.net to get a copy of this message | ||
cox Wed May 29 06:09:09 2002 EDT
Modified files:
/pear/Validate Validate.php
Log:
Allow list of chars as $decimal param for number() (for ex: ".,")
Index: pear/Validate/Validate.php
diff -u pear/Validate/Validate.php:1.6 pear/Validate/Validate.php:1.7
--- pear/Validate/Validate.php:1.6 Wed May 29 05:31:16 2002
+++ pear/Validate/Validate.php Wed May 29 06:09:09 2002
@@ -23,12 +23,12 @@
function number($number, $decimal = null, $dec_prec = null, $min = null, $max = null)
{
$dec_prec = $dec_prec ? "{1,$dec_prec}" : '+';
- $dec_regex = $decimal ? $decimal . '[0-9]' . $dec_prec : '';
+ $dec_regex = $decimal ? "[$decimal][0-9]$dec_prec" : '';
if (!preg_match("|^[-+]?[0-9]+($dec_regex)?\$|", $number)) {
return false;
}
if ($decimal != '.') {
- $number = str_replace($decimal, '.', $number);
+ $number = strtr($number, $decimal, '.');
}
$number = (float)$number;
if ($min !== null && $min > $number) {