diff --git a/core/config/schema/core.data_types.schema.yml b/core/config/schema/core.data_types.schema.yml index 6a19942a29..92782406ca 100644 --- a/core/config/schema/core.data_types.schema.yml +++ b/core/config/schema/core.data_types.schema.yml @@ -284,10 +284,6 @@ config_entity: uuid: type: uuid label: 'UUID' - constraints: - Length: - max: 128 - maxMessage: 'UUID: may not be longer than 128 characters.' langcode: type: string label: 'Language code' diff --git a/core/lib/Drupal/Core/Config/StorableConfigBase.php b/core/lib/Drupal/Core/Config/StorableConfigBase.php index a2752290ea..bc81ab7cc1 100644 --- a/core/lib/Drupal/Core/Config/StorableConfigBase.php +++ b/core/lib/Drupal/Core/Config/StorableConfigBase.php @@ -129,7 +129,7 @@ public function getStorage() { * * @return \Drupal\Core\Config\Schema\Element */ - public function getSchemaWrapper() { + protected function getSchemaWrapper() { if (!isset($this->schemaWrapper)) { $this->schemaWrapper = $this->typedConfigManager->createFromNameAndData($this->name, $this->data); } diff --git a/core/modules/rest/src/Plugin/rest/resource/ConfigEntityResource.php b/core/modules/rest/src/Plugin/rest/resource/ConfigEntityResource.php index d4b98c342f..91d4e89b21 100644 --- a/core/modules/rest/src/Plugin/rest/resource/ConfigEntityResource.php +++ b/core/modules/rest/src/Plugin/rest/resource/ConfigEntityResource.php @@ -13,12 +13,10 @@ class ConfigEntityResource extends EntityResource { * {@inheritdoc} */ protected function validate(EntityInterface $entity) { - /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity */ - $config = \Drupal::configFactory()->getEditable($entity->getConfigDependencyName()); - $config->setData($entity->toArray()); - - $typed_config = $config->getSchemaWrapper(); - + // Use typed config to validate the validate the config entity. + /** @var \Drupal\Core\Config\TypedConfigManagerInterface $type_config_manager */ + $type_config_manager = \Drupal::service('config.typed'); + $typed_config = $type_config_manager->createFromNameAndData($entity->getConfigDependencyName(), $entity->toArray()); $violations = $typed_config->validate(); $this->processViolations($violations); diff --git a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php index 6e9436e63b..5b22991e9a 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php @@ -759,7 +759,7 @@ public function testPost() { $this->assertResourceErrorResponse(422, "Unprocessable Entity: validation failed.\nuuid.0.value: UUID: may not be longer than 128 characters.\n", $response); } else { - $this->assertResourceErrorResponse(422, "Unprocessable Entity: validation failed.\nuuid: UUID: may not be longer than 128 characters.\n", $response); + $this->assertResourceErrorResponse(422, "Unprocessable Entity: validation failed.\nuuid: This is not a valid UUID.\n", $response); } } diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaTest.php index 57ef94dc0c..e2e02e1dc8 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaTest.php @@ -172,12 +172,6 @@ public function testSchemaMapping() { $expected['mapping']['name']['type'] = 'string'; $expected['mapping']['uuid']['type'] = 'uuid'; $expected['mapping']['uuid']['label'] = 'UUID'; - $expected['mapping']['uuid']['constraints'] = [ - 'Length' => [ - 'max' => 128, - 'maxMessage' => 'UUID: may not be longer than 128 characters.', - ], - ]; $expected['mapping']['langcode']['type'] = 'string'; $expected['mapping']['langcode']['label'] = 'Language code'; $expected['mapping']['status']['type'] = 'boolean';