diff --git a/Doctrine/Validator.php b/Doctrine/Validator.php index eecb36f73..ec8008f78 100644 --- a/Doctrine/Validator.php +++ b/Doctrine/Validator.php @@ -183,12 +183,6 @@ class Doctrine_Validator { break; } } - /** - if(self::gettype($value) !== $column[0] && self::gettype($value) != 'NULL') { - $err[$key] = Doctrine_Validator::ERR_TYPE; - continue; - } - */ if( ! self::isValidType($value, $column[0])) { $err[$key] = Doctrine_Validator::ERR_TYPE; continue; diff --git a/Doctrine/Validator/Email.php b/Doctrine/Validator/Email.php index f88756918..54e39f554 100644 --- a/Doctrine/Validator/Email.php +++ b/Doctrine/Validator/Email.php @@ -8,6 +8,9 @@ class Doctrine_Validator_Email { * @return boolean */ public function validate(Doctrine_Record $record, $key, $value, $args) { + if(empty($value)) + return true; + $parts = explode("@", $value); if(count($parts) != 2) diff --git a/tests/ValidatorTestCase.php b/tests/ValidatorTestCase.php index 996b9eb35..7a841f09e 100644 --- a/tests/ValidatorTestCase.php +++ b/tests/ValidatorTestCase.php @@ -81,7 +81,9 @@ class Doctrine_ValidatorTestCase extends Doctrine_UnitTestCase { $this->assertTrue(is_array($stack)); $stack = $stack['Validator_Test'][0]; + $this->assertEqual($stack['mystring'], Doctrine_Validator::ERR_NOTNULL); + $this->assertEqual($stack['myemail2'], Doctrine_Validator::ERR_NOTBLANK); $test->mystring = 'str'; @@ -137,7 +139,7 @@ class Doctrine_ValidatorTestCase extends Doctrine_UnitTestCase { } public function testSave() { $this->manager->setAttribute(Doctrine::ATTR_VLD, true); - $user = $this->session->getTable("User")->find(4); + $user = $this->session->getTable("User")->find(4); try { $user->name = "this is an example of too long name not very good example but an example nevertheless"; $user->save(); diff --git a/tests/classes.php b/tests/classes.php index 1a7230a4e..4ef03e303 100644 --- a/tests/classes.php +++ b/tests/classes.php @@ -382,6 +382,8 @@ class Validator_Test extends Doctrine_Record { $this->hasColumn("myarray", "array", 1000); $this->hasColumn("myobject", "object", 1000); $this->hasColumn("myinteger", "integer", 11); + $this->hasColumn("myemail", "string", 100, "email"); + $this->hasColumn("myemail2", "string", 100, "email|notblank"); } } ?> diff --git a/tests/run.php b/tests/run.php index 817d15a5a..7a20b973d 100644 --- a/tests/run.php +++ b/tests/run.php @@ -34,8 +34,6 @@ $test->addTestCase(new Doctrine_SessionTestCase()); $test->addTestCase(new Doctrine_TableTestCase()); -$test->addTestCase(new Doctrine_ValidatorTestCase()); - $test->addTestCase(new Doctrine_ManagerTestCase()); $test->addTestCase(new Doctrine_AccessTestCase()); @@ -65,6 +63,8 @@ $test->addTestCase(new Doctrine_CustomPrimaryKeyTestCase()); $test->addTestCase(new Doctrine_Filter_TestCase()); $test->addTestCase(new Doctrine_ValueHolder_TestCase()); + +$test->addTestCase(new Doctrine_ValidatorTestCase()); //$test->addTestCase(new Doctrine_Cache_FileTestCase()); //$test->addTestCase(new Doctrine_Cache_SqliteTestCase());