1
0
mirror of synced 2025-01-31 04:21:44 +03:00

Validators updated

This commit is contained in:
doctrine 2006-05-26 11:32:35 +00:00
parent f7a3c2f353
commit cf5b0ef906
4 changed files with 12 additions and 22 deletions

View File

@ -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;
}
}
?>

View File

@ -1,17 +1,5 @@
<?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;

View File

@ -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;
}
}
?>

View File

@ -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");
}
}
?>