Commit 76081664 authored by pookey's avatar pookey

Empty values now pass email validator

parent f5e54ad7
......@@ -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;
......
......@@ -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)
......
......@@ -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();
......
......@@ -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");
}
}
?>
......@@ -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());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment