From: Andrey Kutejko Date: Sat, 8 Jun 2013 15:40:41 +0000 (+0300) Subject: always validate records X-Git-Tag: 0.5~268 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=10831b46fb46694c32e8e4d524862f0f113f7ffc;p=ipf.git always validate records --- diff --git a/ipf/orm.php b/ipf/orm.php index 442e974..72bc2ce 100644 --- a/ipf/orm.php +++ b/ipf/orm.php @@ -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; diff --git a/ipf/orm/configurable.php b/ipf/orm/configurable.php index 3e9f8d6..81f5196 100644 --- a/ipf/orm/configurable.php +++ b/ipf/orm/configurable.php @@ -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: diff --git a/ipf/orm/manager.php b/ipf/orm/manager.php index ee2f721..59da7bc 100644 --- a/ipf/orm/manager.php +++ b/ipf/orm/manager.php @@ -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", diff --git a/ipf/orm/record.php b/ipf/orm/record.php index ec67315..7c366c4 100644 --- a/ipf/orm/record.php +++ b/ipf/orm/record.php @@ -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(); diff --git a/ipf/orm/table.php b/ipf/orm/table.php index 16bdab3..1362af9 100644 --- a/ipf/orm/table.php +++ b/ipf/orm/table.php @@ -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 diff --git a/ipf/project.php b/ipf/project.php index 32f1400..cf34d40 100644 --- a/ipf/project.php +++ b/ipf/project.php @@ -137,7 +137,6 @@ final class IPF_Project{ return false; } $this->loadModels(); - IPF_ORM_Manager::getInstance()->setAttribute(IPF_ORM::ATTR_VALIDATE, IPF_ORM::VALIDATE_ALL); $this->router = new IPF_Router(); $this->router->dispatch(IPF_HTTP_URL::getAction()); return true;