summaryrefslogtreecommitdiffstats
path: root/system/libraries/Form_validation.php
diff options
context:
space:
mode:
authorPhil Sturgeon <email@philsturgeon.co.uk>2011-02-15 22:26:16 +0100
committerPhil Sturgeon <email@philsturgeon.co.uk>2011-02-15 22:26:16 +0100
commitd98325db8019d7ed71906d63442c694da038fcf7 (patch)
treeca03aff84e95efc5cf69776c22772f82dd060806 /system/libraries/Form_validation.php
parentff1cfa1ae5c5440bfde35c36ecb4cdcd73cd3966 (diff)
parent17d184dad3a5b28f209e346e53d9956988e0c4a3 (diff)
Automated merge with https://bitbucket.org/seandowney/codeigniter-reactor
Diffstat (limited to 'system/libraries/Form_validation.php')
-rw-r--r--system/libraries/Form_validation.php72
1 files changed, 61 insertions, 11 deletions
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index fc5b82ee3..adfd17db1 100644
--- 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);
}
// --------------------------------------------------------------------