From 12f9cc8fc102389bd232f35921b4bd6c4daa9c31 Mon Sep 17 00:00:00 2001 From: Derek Allard Date: Tue, 22 Jan 2008 07:21:32 +0000 Subject: Changed "numeric" to use is_numeric() and added an "integer" rule into the Validation library. --- system/libraries/Validation.php | 14 +++++++------- user_guide/changelog.html | 7 ++++--- user_guide/libraries/validation.html | 14 ++++++++++---- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/system/libraries/Validation.php b/system/libraries/Validation.php index d96b4f6f6..dc4e016bc 100644 --- a/system/libraries/Validation.php +++ b/system/libraries/Validation.php @@ -7,8 +7,8 @@ * @package CodeIgniter * @author ExpressionEngine Dev Team * @copyright Copyright (c) 2006, EllisLab, Inc. - * @license http://codeigniter.com/user_guide/license.html - * @link http://codeigniter.com + * @license http://www.codeigniter.com/user_guide/license.html + * @link http://www.codeigniter.com * @since Version 1.0 * @filesource */ @@ -22,7 +22,7 @@ * @subpackage Libraries * @category Validation * @author ExpressionEngine Dev Team - * @link http://codeigniter.com/user_guide/libraries/validation.html + * @link http://www.codeigniter.com/user_guide/libraries/validation.html */ class CI_Validation { @@ -552,21 +552,21 @@ class CI_Validation { */ function numeric($str) { - return ! preg_match('/[^0-9]/', $str); + return ( ! is_numeric($str)) ? FALSE : TRUE; } // -------------------------------------------------------------------- /** - * Is Numeric + * Integer * * @access public * @param string * @return bool */ - function is_numeric($str) + function integer($str) { - return ( ! is_numeric($str)) ? FALSE : TRUE; + return ( ! is_int($str)) ? FALSE : TRUE; } // -------------------------------------------------------------------- diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 95be683d3..78861b44b 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -110,10 +110,11 @@ Change Log diff --git a/user_guide/libraries/validation.html b/user_guide/libraries/validation.html index c2b9b9647..f9cac856b 100644 --- a/user_guide/libraries/validation.html +++ b/user_guide/libraries/validation.html @@ -576,11 +576,18 @@ For example, your "username" error will be available at:
$this->valida No Returns FALSE if the form element contains anything other than alpha-numeric characters, underscores or dashes.   - + + + numeric + No + Returns FALSE if the form element contains anything other than numeric characters. +   + + -numeric +integer No -Returns FALSE if the form element contains anything other than numeric characters. +Returns FALSE if the form element contains anything other than an integer.   @@ -595,7 +602,6 @@ For example, your "username" error will be available at:
$this->valida Returns FALSE if the supplied IP is not valid.   -

Note: These rules can also be called as discreet functions. For example:

-- cgit v1.2.3-24-g4f1b