diff --git a/core/lib/Drupal/Core/TypedData/TypedDataManager.php b/core/lib/Drupal/Core/TypedData/TypedDataManager.php index c200e43..8e9d148 100644 --- a/core/lib/Drupal/Core/TypedData/TypedDataManager.php +++ b/core/lib/Drupal/Core/TypedData/TypedDataManager.php @@ -378,6 +378,14 @@ public function getConstraints($definition) { $constraints[] = $validation_manager->create('NotNull', array()); } + // If the definition does not provide a class use the class from the type + // definition for performing interface checks. + $class = isset($definition['class']) ? $definition['class'] : $type_definition['class']; + // Check if the class provides allowed values. + if (array_key_exists('Drupal\Core\TypedData\AllowedValuesInterface', class_implements($class)) && array_key_exists('Drupal\Core\TypedData\PrimitiveInterface', class_implements($class))) { + $constraints[] = $validation_manager->create('AllowedValues', array()); + } + return $constraints; } }