summaryrefslogtreecommitdiffstats
path: root/system/libraries/Form_validation.php
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@server-speed.net>2011-04-10 10:39:31 +0200
committerFlorian Pritz <bluewind@server-speed.net>2011-04-10 10:39:31 +0200
commit1bdc9c8903eb2db33fdb8174d61e15100dfbbca8 (patch)
treeb0c645ad99e04f34817fc4e6385792111db42274 /system/libraries/Form_validation.php
parent413d0cdac49257089a0790f6ac92973a36a6b69f (diff)
update to CI 2.0.2
Signed-off-by: Florian Pritz <bluewind@server-speed.net>
Diffstat (limited to 'system/libraries/Form_validation.php')
-rwxr-xr-xsystem/libraries/Form_validation.php77
1 files changed, 61 insertions, 16 deletions
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index fc5b82ee3..cfc02eda9 100755
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -138,14 +138,14 @@ class CI_Form_validation {
// Build our master array
$this->_field_data[$field] = array(
- 'field' => $field,
- 'label' => $label,
- 'rules' => $rules,
- 'is_array' => $is_array,
- 'keys' => $indexes,
- 'postdata' => NULL,
- 'error' => ''
- );
+ 'field' => $field,
+ 'label' => $label,
+ 'rules' => $rules,
+ 'is_array' => $is_array,
+ 'keys' => $indexes,
+ 'postdata' => NULL,
+ 'error' => ''
+ );
return $this;
}
@@ -1040,7 +1040,7 @@ class CI_Form_validation {
return $this->valid_email(trim($str));
}
- foreach(explode(',', $str) as $email)
+ foreach (explode(',', $str) as $email)
{
if (trim($email) != '' && $this->valid_email(trim($email)) === FALSE)
{
@@ -1147,7 +1147,57 @@ class CI_Form_validation {
*/
function integer($str)
{
- return (bool)preg_match( '/^[\-+]?[0-9]+$/', $str);
+ return (bool) preg_match('/^[\-+]?[0-9]+$/', $str);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Decimal number
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function decimal($str)
+ {
+ return (bool) preg_match('/^[\-+]?[0-9]+\.[0-9]+$/', $str);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Greather than
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function greater_than($str, $min)
+ {
+ if ( ! is_numeric($str))
+ {
+ return FALSE;
+ }
+ return $str > $min;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Less than
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function less_than($str, $max)
+ {
+ if ( ! is_numeric($str))
+ {
+ return FALSE;
+ }
+ return $str < $max;
}
// --------------------------------------------------------------------
@@ -1161,7 +1211,7 @@ class CI_Form_validation {
*/
function is_natural($str)
{
- return (bool)preg_match( '/^[0-9]+$/', $str);
+ return (bool) preg_match( '/^[0-9]+$/', $str);
}
// --------------------------------------------------------------------
@@ -1286,11 +1336,6 @@ class CI_Form_validation {
*/
function xss_clean($str)
{
- if ( ! isset($this->CI->security))
- {
- $this->CI->load->library('security');
- }
-
return $this->CI->security->xss_clean($str);
}