Commit cf5b0ef9 authored by doctrine's avatar doctrine

Validators updated

parent f7a3c2f3
......@@ -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;
}
}
?>
<?php
class Doctrine_Validator_Range {
/**
* @param integer $max
*/
public function setMin($min) {
$this->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;
......
......@@ -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;
}
}
?>
......@@ -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");
}
}
?>
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