Skip to content

Commit

Permalink
DDC-1530 - Validate field types in SchemaValidator
Browse files Browse the repository at this point in the history
  • Loading branch information
beberlei committed Dec 19, 2011
1 parent 4f67ea3 commit 40800bd
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/Doctrine/ORM/Tools/SchemaValidator.php
Expand Up @@ -21,6 +21,7 @@

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping\ClassMetadataInfo;
use Doctrine\DBAL\Types\Type;

/**
* Performs strict validation of the mapping schema
Expand Down Expand Up @@ -87,6 +88,12 @@ public function validateClass(ClassMetadataInfo $class)
$ce = array();
$cmf = $this->em->getMetadataFactory();

foreach ($class->fieldMappings as $fieldName => $mapping) {
if (!Type::hasType($mapping['type'])) {
$ce[] = "The field '" . $class->name . "#" . $fieldName."' uses a non-existant type '" . $mapping['type'] . "'.";
}
}

foreach ($class->associationMappings AS $fieldName => $assoc) {
if (!$cmf->hasMetadataFor($assoc['targetEntity'])) {
$ce[] = "The target entity '" . $assoc['targetEntity'] . "' specified on " . $class->name . '#' . $fieldName . ' is unknown.';
Expand Down

0 comments on commit 40800bd

Please sign in to comment.