From fadef335c4d2a15793a344a388fb6f0e84812553 Mon Sep 17 00:00:00 2001 From: zYne Date: Mon, 11 Sep 2006 20:51:24 +0000 Subject: [PATCH] Validator now supports all doctrine types --- Doctrine/Validator.php | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/Doctrine/Validator.php b/Doctrine/Validator.php index cd008e7ea..c3c1e22ff 100644 --- a/Doctrine/Validator.php +++ b/Doctrine/Validator.php @@ -224,6 +224,27 @@ class Doctrine_Validator { public function getErrorStack() { return $this->stack; } + /** + * converts a doctrine type to native php type + * + * @param $doctrineType + * @return string + */ + public function phpType($doctrineType) { + switch($doctrineType) { + case 'enum': + return 'integer'; + case 'blob': + case 'clob': + case 'mbstring': + case 'timestamp': + case 'date': + return 'string'; + break; + default: + return $doctrineType; + } + } /** * returns whether or not the given variable is * valid type @@ -237,10 +258,7 @@ class Doctrine_Validator { return true; $looseType = self::gettype($var); - if($type == 'enum') - $type = 'integer'; - elseif($type == 'date' || $type == 'clob') - $type = 'string'; + $type = self::phpType($type); switch($looseType): case 'float':