summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/libraries/Validation.php30
1 files changed, 29 insertions, 1 deletions
diff --git a/system/libraries/Validation.php b/system/libraries/Validation.php
index f5e4d2223..a0423c7b6 100644
--- a/system/libraries/Validation.php
+++ b/system/libraries/Validation.php
@@ -614,7 +614,35 @@ class CI_Validation {
{
return (bool)preg_match( '/^[\-+]?[0-9]+$/', $str);
}
-
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Is a Natural number (0,1,2,3, etc.)
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function is_natural($str)
+ {
+ return (bool)preg_match( '/^[0-9]+$/', $str);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Is a Natural number, but not a zero (1,2,3, etc.)
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function is_natural_no_zero($str)
+ {
+ return (bool)preg_match( '/^[1-9]+$/', $str);
+ }
+
// --------------------------------------------------------------------
/**