OSDN Git Service

add ACS webapp, sql, htdocs
[acs/acs.git] / webapp / lib / class / ACSErrorCheck.class.php
diff --git a/webapp/lib/class/ACSErrorCheck.class.php b/webapp/lib/class/ACSErrorCheck.class.php
new file mode 100644 (file)
index 0000000..6c384a4
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+// $Id: ACSErrorCheck.class.php,v 1.3 2007/03/01 09:01:12 w-ota Exp $
+
+/**
+ * ¥¨¥é¡¼¥Á¥§¥Ã¥¯´Ø¿ô
+ */
+class ACSErrorCheck
+{
+       /**
+        * ÆüÉÕ¤¬Àµ¤·¤¤¤«
+        * 
+        * @param ÆüÉÕ¤òɽ¤¹Ê¸»úÎó (YYYY/MM/DD)
+        * @return Àµ(true) / ¸í(false)
+        */
+       static function is_valid_date($str) {
+               list($yyyy, $mm, $dd) = explode('/', $str);
+               if (preg_match('/^[0-9]{4}\/[0-9]{2}\/[0-9]{2}$/', $str) && checkdate($mm, $dd, $yyyy)) {
+                       return true;
+               } else {
+                       return false;
+               }
+       }
+
+       /**
+        * ¼«Á³¿ô¤«¤É¤¦¤«
+        *
+        * @param $str È½Äꤹ¤ëʸ»úÎó
+        * @param $enable_zero £°¤ò´Þ¤à¤«Èݤ«
+        * @return Àµ(true) / ¸í(false)
+        */
+       function is_natural_number($str,$enable_zero=false) {
+               $min = $enable_zero===true ? 0 : 1;
+               if (preg_match('/^[0-9]+$/', $str) && $str >= $min) {
+                       return true;
+               } else {
+                       return false;
+               }
+       }
+}
+
+?>