diff --git a/core/lib/Drupal/Core/Config/Plugin/Validation/Constraint/ConfigExistsConstraintValidator.php b/core/lib/Drupal/Core/Config/Plugin/Validation/Constraint/ConfigExistsConstraintValidator.php
index fbc7542a7de9a26db91ea20cef5504416ef38f86..9f6d1188dc88fe04c16279c1e44ce5d25fb0a72b 100644
--- a/core/lib/Drupal/Core/Config/Plugin/Validation/Constraint/ConfigExistsConstraintValidator.php
+++ b/core/lib/Drupal/Core/Config/Plugin/Validation/Constraint/ConfigExistsConstraintValidator.php
@@ -5,6 +5,7 @@
 namespace Drupal\Core\Config\Plugin\Validation\Constraint;
 
 use Drupal\Core\Config\ConfigFactoryInterface;
+use Drupal\Core\Config\Schema\TypeResolver;
 use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 use Symfony\Component\Validator\Constraint;
@@ -50,6 +51,8 @@ public function validate(mixed $name, Constraint $constraint): void {
       return;
     }
 
+    $constraint->prefix = TypeResolver::resolveDynamicTypeName($constraint->prefix, $this->context->getObject());
+
     if (!in_array($constraint->prefix . $name, $this->configFactory->listAll($constraint->prefix), TRUE)) {
       $this->context->addViolation($constraint->message, ['@name' => $constraint->prefix . $name]);
     }
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigExistsConstraintValidatorTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigExistsConstraintValidatorTest.php
index bcdc76cc71d7b6343957e6b5434d0fa64e3d1656..3d3ee862cef6e3be3622a5eb0adb781f4d5649dc 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigExistsConstraintValidatorTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigExistsConstraintValidatorTest.php
@@ -28,6 +28,7 @@ class ConfigExistsConstraintValidatorTest extends KernelTestBase {
    *
    * @testWith [{}, "system.site", "system.site"]
    *           [{"prefix": "system."}, "site", "system.site"]
+   *           [{"prefix": "system.[%parent.reference]."}, "admin", "system.menu.admin"]
    */
   public function testValidation(array $constraint_options, string $value, string $expected_config_name): void {
     // Create a data definition that specifies the value must be a string with
@@ -37,7 +38,11 @@ public function testValidation(array $constraint_options, string $value, string
 
     /** @var \Drupal\Core\TypedData\TypedDataManagerInterface $typed_data */
     $typed_data = $this->container->get('typed_data_manager');
-    $data = $typed_data->create($definition, $value);
+
+    // Create a data definition for the parent data.
+    $parent_data_definition = $typed_data->createDataDefinition('map');
+    $parent_data = $typed_data->create($parent_data_definition, ['reference' => 'menu']);
+    $data = $typed_data->create($definition, $value, 'data_name', $parent_data);
 
     $violations = $data->validate();
     $this->assertCount(1, $violations);