]> git.andy128k.dev Git - ipf-legacy-orm.git/commitdiff
always validate records
authorAndrey Kutejko <andy128k@gmail.com>
Sat, 8 Jun 2013 15:40:41 +0000 (18:40 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Sat, 8 Jun 2013 15:40:41 +0000 (18:40 +0300)
ipf/orm.php
ipf/orm/configurable.php
ipf/orm/manager.php
ipf/orm/record.php
ipf/orm/table.php

index 442e9749731fe774b8a03d97572b4ee925f89789..72bc2ceb1dc5b5ff88621e8e4a916af674b8d91c 100644 (file)
@@ -112,7 +112,6 @@ final class IPF_ORM {
     const ATTR_DECIMAL_PLACES       = 141;
 
     const ATTR_PORTABILITY          = 106;
-    const ATTR_VALIDATE             = 107;
     const ATTR_COLL_KEY             = 108;
     const ATTR_QUERY_LIMIT          = 109;
     const ATTR_DEFAULT_TABLE_TYPE   = 112;
@@ -178,11 +177,6 @@ final class IPF_ORM {
     const HYDRATE_ARRAY             = 3;
 
     const HYDRATE_NONE              = 4;
-    const VALIDATE_NONE             = 0;
-    const VALIDATE_LENGTHS          = 1;
-    const VALIDATE_TYPES            = 2;
-    const VALIDATE_CONSTRAINTS      = 4;
-    const VALIDATE_ALL              = 7;
     const IDENTIFIER_AUTOINC        = 1;
     const IDENTIFIER_SEQUENCE       = 2;
     const IDENTIFIER_NATURAL        = 3;
index 3e9f8d661be4961260948b5c180b121ced64a58c..81f51964d6d0f704698aca0fb3d49cc2b43687be 100644 (file)
@@ -65,7 +65,6 @@ abstract class IPF_ORM_Configurable extends IPF_ORM_Locator_Injectable
                     }
                 }
                 break;
-            case IPF_ORM::ATTR_VALIDATE:
             case IPF_ORM::ATTR_QUERY_LIMIT:
             case IPF_ORM::ATTR_QUOTE_IDENTIFIER:
             case IPF_ORM::ATTR_PORTABILITY:
index ee2f721d229832bc6e955e21e35d4492279b75af..59da7bc484e7a7f55691eb4cdeeea302fb398872 100644 (file)
@@ -26,7 +26,6 @@ class IPF_ORM_Manager extends IPF_ORM_Configurable implements Countable, Iterato
                         IPF_ORM::ATTR_LISTENER                 => new IPF_ORM_EventListener(),
                         IPF_ORM::ATTR_RECORD_LISTENER          => new IPF_ORM_Record_Listener(),
                         IPF_ORM::ATTR_THROW_EXCEPTIONS         => true,
-                        IPF_ORM::ATTR_VALIDATE                 => IPF_ORM::VALIDATE_NONE,
                         IPF_ORM::ATTR_QUERY_LIMIT              => IPF_ORM::LIMIT_RECORDS,
                         IPF_ORM::ATTR_IDXNAME_FORMAT           => "%s_idx",
                         IPF_ORM::ATTR_SEQNAME_FORMAT           => "%s_seq",
index ec67315ccc739cdc4a43e3c975e2a2c162ddf526..7c366c4578c400fb6ecf67301e5997d34d3a4da1 100644 (file)
@@ -98,9 +98,6 @@ abstract class IPF_ORM_Record extends IPF_ORM_Record_Abstract implements Countab
 
     public function isValid()
     {
-        if ( ! $this->_table->getAttribute(IPF_ORM::ATTR_VALIDATE)) {
-            return true;
-        }
         // Clear the stack from any previous errors.
         $this->getErrorStack()->clear();
 
index 16bdab3899ea50a17aa738ed778ac0bb0b7461f0..1362af9cd7f0d9107e734026ffcaa8e668e86c46 100644 (file)
@@ -1026,24 +1026,20 @@ class IPF_ORM_Table extends IPF_ORM_Configurable implements Countable
 
         $dataType = $this->getTypeOf($fieldName);
 
-        // Validate field type, if type validation is enabled
-        if ($this->getAttribute(IPF_ORM::ATTR_VALIDATE) & IPF_ORM::VALIDATE_TYPES) {
-            if ( ! IPF_ORM_Validator::isValidType($value, $dataType)) {
-                $errorStack->add($fieldName, 'type');
-            }
-            if ($dataType == 'enum') {
-                $enumIndex = $this->enumIndex($fieldName, $value);
-                if ($enumIndex === false) {
-                    $errorStack->add($fieldName, 'enum');
-                }
+        // Validate field type
+        if ( ! IPF_ORM_Validator::isValidType($value, $dataType)) {
+            $errorStack->add($fieldName, 'type');
+        }
+        if ($dataType == 'enum') {
+            $enumIndex = $this->enumIndex($fieldName, $value);
+            if ($enumIndex === false) {
+                $errorStack->add($fieldName, 'enum');
             }
         }
 
-        // Validate field length, if length validation is enabled
-        if ($this->getAttribute(IPF_ORM::ATTR_VALIDATE) & IPF_ORM::VALIDATE_LENGTHS) {
-            if ( ! IPF_ORM_Validator::validateLength($value, $dataType, $this->getFieldLength($fieldName))) {
-                $errorStack->add($fieldName, 'length');
-            }
+        // Validate field length
+        if ( ! IPF_ORM_Validator::validateLength($value, $dataType, $this->getFieldLength($fieldName))) {
+            $errorStack->add($fieldName, 'length');
         }
 
         // Run all custom validators