summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichiel Vugteveen <michiel@it-can.nl>2012-06-15 11:56:24 +0200
committerMichiel Vugteveen <michiel@it-can.nl>2012-06-15 11:56:24 +0200
commitceaf887a7a849eab95b1bed1a837e2e3a1720c99 (patch)
tree4eae2bdb64da156432561698ba46ce03f0c32f41
parent64cfef0fb8cf6254cb08a0c2e3aef04cd5721942 (diff)
some optimizations
-rw-r--r--system/libraries/Form_validation.php30
1 files changed, 21 insertions, 9 deletions
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index 621316c4a..6d4446d0c 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -998,14 +998,18 @@ class CI_Form_validation {
*/
public function min_length($str, $val)
{
- if (preg_match('/[^0-9]/', $val))
+ if ( ! is_numeric($val))
{
return FALSE;
}
+ else
+ {
+ $val = (int) $val;
+ }
return (MB_ENABLED === TRUE)
- ? (intval($val) <= mb_strlen($str))
- : (intval($val) <= strlen($str));
+ ? ($val <= mb_strlen($str))
+ : ($val <= strlen($str));
}
// --------------------------------------------------------------------
@@ -1019,14 +1023,18 @@ class CI_Form_validation {
*/
public function max_length($str, $val)
{
- if (preg_match('/[^0-9]/', $val))
+ if ( ! is_numeric($val))
{
return FALSE;
}
+ else
+ {
+ $val = (int) $val;
+ }
return (MB_ENABLED === TRUE)
- ? (intval($val) >= mb_strlen($str))
- : (intval($val) >= strlen($str));
+ ? ($val >= mb_strlen($str))
+ : ($val >= strlen($str));
}
// --------------------------------------------------------------------
@@ -1040,14 +1048,18 @@ class CI_Form_validation {
*/
public function exact_length($str, $val)
{
- if (preg_match('/[^0-9]/', $val))
+ if ( ! is_numeric($val))
{
return FALSE;
}
+ else
+ {
+ $val = (int) $val;
+ }
return (MB_ENABLED === TRUE)
- ? (mb_strlen($str) === intval($val))
- : (strlen($str) === intval($val));
+ ? (mb_strlen($str) === $val)
+ : (strlen($str) === $val);
}
// --------------------------------------------------------------------