Loading core/lib/Drupal/Core/Config/Plugin/Validation/Constraint/ConfigExistsConstraintValidator.php +5 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,11 @@ public static function create(ContainerInterface $container) { * {@inheritdoc} */ public function validate(mixed $name, Constraint $constraint) { // This constraint may be used to validate nullable (optional) values. if ($name === NULL) { return; } if (!in_array($name, $this->configFactory->listAll(), TRUE)) { $this->context->addViolation($constraint->message, ['@name' => $name]); } Loading core/tests/Drupal/KernelTests/Core/Config/ConfigExistsConstraintValidatorTest.php +4 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,10 @@ public function testValidation(): void { $this->installConfig('system'); $this->assertCount(0, $data->validate()); // NULL should not trigger a validation error: a value may be nullable. $data->setValue(NULL); $this->assertCount(0, $data->validate()); } } Loading
core/lib/Drupal/Core/Config/Plugin/Validation/Constraint/ConfigExistsConstraintValidator.php +5 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,11 @@ public static function create(ContainerInterface $container) { * {@inheritdoc} */ public function validate(mixed $name, Constraint $constraint) { // This constraint may be used to validate nullable (optional) values. if ($name === NULL) { return; } if (!in_array($name, $this->configFactory->listAll(), TRUE)) { $this->context->addViolation($constraint->message, ['@name' => $name]); } Loading
core/tests/Drupal/KernelTests/Core/Config/ConfigExistsConstraintValidatorTest.php +4 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,10 @@ public function testValidation(): void { $this->installConfig('system'); $this->assertCount(0, $data->validate()); // NULL should not trigger a validation error: a value may be nullable. $data->setValue(NULL); $this->assertCount(0, $data->validate()); } }