diff --git a/classes/Validator/Notnull.class.php b/classes/Validator/Notnull.class.php index 93514cd6f..f1d89ef86 100644 --- a/classes/Validator/Notnull.class.php +++ b/classes/Validator/Notnull.class.php @@ -7,7 +7,10 @@ class Doctrine_Validator_Notnull { * @return boolean */ public function validate(Doctrine_Record $record, $key, $value) { - return ($value === null); + if ($value === null) + return false; + + return true; } } ?> diff --git a/classes/Validator/Range.class.php b/classes/Validator/Range.class.php index bc00f13fe..19bd3d3d5 100644 --- a/classes/Validator/Range.class.php +++ b/classes/Validator/Range.class.php @@ -1,17 +1,5 @@ min = $min; - } - /** - * @param integer $max - */ - public function setMax($max) { - $this->max = $max; - } /** * @param Doctrine_Record $record * @param string $key @@ -20,10 +8,11 @@ class Doctrine_Validator_Range { * @return boolean */ public function validate(Doctrine_Record $record, $key, $value, $args) { - if($var < $this->min) + $e = explode("-",$args); + if($value < $e[0]) return false; - - if($var > $this->max) + + if(isset($e[1]) && $value > $e[1]) return false; return true; diff --git a/classes/Validator/Regexp.class.php b/classes/Validator/Regexp.class.php index 97f9691bd..d66d9c309 100644 --- a/classes/Validator/Regexp.class.php +++ b/classes/Validator/Regexp.class.php @@ -8,7 +8,10 @@ class Doctrine_Validator_Regexp { * @return boolean */ public function validate(Doctrine_Record $record, $key, $value, $args) { - return $value; + if(preg_match("/$args/", $value)) + return true; + + return false; } } ?> diff --git a/tests/classes.php b/tests/classes.php index a5e6c65b9..50cf51a76 100644 --- a/tests/classes.php +++ b/tests/classes.php @@ -124,9 +124,6 @@ class Album extends Doctrine_Record { } } class Song extends Doctrine_Record { - public function setUp() { - $this->hasColumn("genre","string","30"); - } public function setTableDefinition() { $this->hasColumn("album_id","integer"); $this->hasColumn("genre","string",20); @@ -210,6 +207,4 @@ class Forum_Thread extends Doctrine_Record { $this->ownsMany("Forum_Entry as Entries", "Forum_Entry.thread_id"); } } - - ?>