[pLog-svn] r5799 - in plog/trunk/class/data/validator: . rules

oscar at devel.lifetype.net oscar at devel.lifetype.net
Sun Aug 5 17:07:05 EDT 2007


Author: oscar
Date: 2007-08-05 17:07:04 -0400 (Sun, 05 Aug 2007)
New Revision: 5799

Removed:
   plog/trunk/class/data/validator/validation.class.php
Modified:
   plog/trunk/class/data/validator/rules/rule.class.php
   plog/trunk/class/data/validator/validator.class.php
Log:
We don't need the Validation class at the top of both the Validator and Rules hierarchy.


Modified: plog/trunk/class/data/validator/rules/rule.class.php
===================================================================
--- plog/trunk/class/data/validator/rules/rule.class.php	2007-08-05 20:46:10 UTC (rev 5798)
+++ plog/trunk/class/data/validator/rules/rule.class.php	2007-08-05 21:07:04 UTC (rev 5799)
@@ -1,7 +1,5 @@
 <?php
 
-    lt_include( PLOG_CLASS_PATH."class/data/validator/validation.class.php");
-
     /**
      * \defgroup Validator_Rules
      *
@@ -34,17 +32,44 @@
      * 'false' otherwise. Please use Validation::_setError() to set additional error codes reporting
      * more information.
      */
-    class Rule extends Validation
+    class Rule
     {
+		private $_error;	
+	
         /**
          * The constructor does nothing.
          */
         function Rule()
         {
-            $this->Validation();
+            $this->_error = false;	
         }
 
         /**
+         * Set a custom error code or message
+         * 
+         * @param error The new error code
+         */
+        function _setError($error)
+        {
+            $this->_error = $error;
+        }
+
+        /**
+         * For client classes, use this method to retrieve the custom error code which was (if any)
+         * that was set in the validate() method. 
+         *
+         * It is not guaranteed that an unsuccessful result of the validate() method will set a custom
+         * error message, as that is completely up to the Validator class. Also depending on the 
+         * class we might get different return values from this method.
+         *
+         * @return An extended error message
+         */
+        function getError()
+        {
+            return $this->_error;
+        }
+
+        /**
          * Validates the data. Does nothing here and it must be reimplemented by
          * every child class.
          *

Deleted: plog/trunk/class/data/validator/validation.class.php
===================================================================
--- plog/trunk/class/data/validator/validation.class.php	2007-08-05 20:46:10 UTC (rev 5798)
+++ plog/trunk/class/data/validator/validation.class.php	2007-08-05 21:07:04 UTC (rev 5799)
@@ -1,65 +0,0 @@
-<?php
-
-    /**
-     * \ingroup Validator
-     *
-     * This is the base class that the Rule classes implement. Classes extending this one
-     * can use the private method _setError for raising custom error codes (in addition to 
-     * returning 'false' from the validate() method)
-     *
-     * Client classes can use the public method getError() to retrieve this error codes
-     * and perhaps show a more meaningful message based on its value (if any)
-     */
-    class Validation 
-    {
-        var $_error;
-
-        /**
-         * Initialize the validation scheme
-         */
-        function Validation()
-        {
-            
-            $this->_error = false;
-        }
-
-        /**
-         * Set a custom error code or message
-         * 
-         * @param error The new error code
-         */
-        function _setError($error)
-        {
-            $this->_error = $error;
-        }
-
-        /**
-         * For client classes, use this method to retrieve the custom error code which was (if any)
-         * that was set in the validate() method. 
-         *
-         * It is not guaranteed that an unsuccessful result of the validate() method will set a custom
-         * error message, as that is completely up to the Validator class. Also depending on the 
-         * class we might get different return values from this method.
-         *
-         * @return An extended error message
-         */
-        function getError()
-        {
-            return $this->_error;
-        }
-
-        /**
-         * Implementation of the validation logic
-         *
-         * @param value The value that we're going to validate
-         * @return true if successful or false otherwise
-         * @see Rule::validate()
-         * @see Validator::validate()
-         */
-        function validate($value)
-        {
-            throw(new Exception("Validation::validate: This method must be implemented by child classes."));
-            die();
-        }
-    }
-?>
\ No newline at end of file

Modified: plog/trunk/class/data/validator/validator.class.php
===================================================================
--- plog/trunk/class/data/validator/validator.class.php	2007-08-05 20:46:10 UTC (rev 5798)
+++ plog/trunk/class/data/validator/validator.class.php	2007-08-05 21:07:04 UTC (rev 5799)
@@ -43,28 +43,50 @@
      * </pre>
      */
 
-	lt_include( PLOG_CLASS_PATH."class/data/validator/validation.class.php" );
-
     /**
      * \ingroup Validator
      *
      * Base class that all other validators extend. See the documentation of the Validator module for more
      * information.
      */
-    class Validator extends Validation 
-    {
-    
-        var $_rules;
+    abstract class Validator
+    {    
+        private $_rules;
+		private $_error;
 
     	/**
          * Initializes the constructor
          */
     	function Validator()
         {
-            $this->Validation();
-            
+            $this->_error = false;            
             $this->_rules = array();
         }
+
+        /**
+         * Set a custom error code or message
+         * 
+         * @param error The new error code
+         */
+        private function _setError($error)
+        {
+            $this->_error = $error;
+        }
+
+        /**
+         * For client classes, use this method to retrieve the custom error code which was (if any)
+         * that was set in the validate() method. 
+         *
+         * It is not guaranteed that an unsuccessful result of the validate() method will set a custom
+         * error message, as that is completely up to the Validator class. Also depending on the 
+         * class we might get different return values from this method.
+         *
+         * @return An extended error message
+         */
+        function getError()
+        {
+            return $this->_error;
+        }
         
         /**
          * Adds a rule to the Validator



More information about the pLog-svn mailing list