diff options
author | Derek Allard <derek.allard@ellislab.com> | 2008-01-22 08:21:32 +0100 |
---|---|---|
committer | Derek Allard <derek.allard@ellislab.com> | 2008-01-22 08:21:32 +0100 |
commit | 12f9cc8fc102389bd232f35921b4bd6c4daa9c31 (patch) | |
tree | 853a9769a6a15be397032a4844aa03c0326463e4 | |
parent | da9ee1a658d03c4dbfc64d658e3ab5205550e3c7 (diff) |
Changed "numeric" to use is_numeric() and added an "integer" rule into the Validation library.
-rw-r--r-- | system/libraries/Validation.php | 14 | ||||
-rw-r--r-- | user_guide/changelog.html | 7 | ||||
-rw-r--r-- | 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 <ul>
<li>Added Flashdata variables, session_id regeneration and configurable session update times to the <a href="./libraries/sessions.html">Session class.</a></li>
<li>Added a language entry for valid_ip validation error.</li>
- <li>Moved the safe mode and auth checks for the Email library into the constructor. </li>
- <li>Modified prep_for_form() in the Validation class to accept arrays, adding support for POST array validation (via callbacks only)</li>
- <li>Changed the behaviour of custom callbacks so that they no longer trigger the "required" rule. </li>
+ <li>Modified prep_for_form() in the Validation class to accept arrays, adding support for POST array validation (via callbacks only)</li>
+ <li>Changed "numeric" to use is_numeric() and added an "integer" rule into the <a href="./libraries/validation.html">Validation</a> library.</li>
+ <li>Changed the behaviour of custom callbacks so that they no longer trigger the "required" rule. </li>
<li>Modified Upload class $_FILES error messages to be more precise.</li>
+ <li>Moved the safe mode and auth checks for the Email library into the constructor. </li>
<li>Modified variable names in _ci_load() method of Loader class to avoid conflicts with view variables.</li>
<li>Added a few additional mime type variations for CSV.</li>
</ul>
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:<br /><dfn>$this->valida <td class="td">No</td>
<td class="td">Returns FALSE if the form element contains anything other than alpha-numeric characters, underscores or dashes.</td>
<td class="td"> </td>
-</tr><tr>
+</tr>
+<tr>
+ <td class="td"><strong>numeric</strong></td>
+ <td class="td">No</td>
+ <td class="td">Returns FALSE if the form element contains anything other than numeric characters.</td>
+ <td class="td"> </td>
+</tr>
+<tr>
-<td class="td"><strong>numeric</strong></td>
+<td class="td"><strong>integer</strong></td>
<td class="td">No</td>
-<td class="td">Returns FALSE if the form element contains anything other than numeric characters.</td>
+<td class="td">Returns FALSE if the form element contains anything other than an integer.</td>
<td class="td"> </td>
</tr><tr>
@@ -595,7 +602,6 @@ For example, your "username" error will be available at:<br /><dfn>$this->valida <td class="td">Returns FALSE if the supplied IP is not valid.</td>
<td class="td"> </td>
</tr>
-
</table>
<p><strong>Note:</strong> These rules can also be called as discreet functions. For example:</p>
|