Skip to content
Snippets Groups Projects
Commit a7d396f1 authored by catch's avatar catch
Browse files

Issue #3416549 by Wim Leers: ConfigExistsConstraintValidator should ignore NULL values

(cherry picked from commit 97c49565)
parent 64a66d9a
No related branches found
No related tags found
9 merge requests!8376Drupal views: adding more granularity to the ‘use ajax’ functionality,!8300Issue #3443586 View area displays even when parent view has no results.,!7567Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7565Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7509Change label "Block description" to "Block type",!7344Issue #3292350 by O'Briat, KlemenDEV, hswong3i, smustgrave, quietone: Update...,!6922Issue #3412959 by quietone, smustgrave, longwave: Fix 12 'un' words,!6848Issue #3417553 by longwave: Remove withConsecutive() in CacheCollectorTest,!6720Revert "Issue #3358581 by pfrenssen, _tarik_, a.dmitriiev, smustgrave:...
Pipeline #91165 passed
Pipeline: drupal

#91191

    Pipeline: drupal

    #91185

      Pipeline: drupal

      #91182

        +1
        ...@@ -43,6 +43,11 @@ public static function create(ContainerInterface $container) { ...@@ -43,6 +43,11 @@ public static function create(ContainerInterface $container) {
        * {@inheritdoc} * {@inheritdoc}
        */ */
        public function validate(mixed $name, Constraint $constraint) { 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)) { if (!in_array($name, $this->configFactory->listAll(), TRUE)) {
        $this->context->addViolation($constraint->message, ['@name' => $name]); $this->context->addViolation($constraint->message, ['@name' => $name]);
        } }
        ......
        ...@@ -40,6 +40,10 @@ public function testValidation(): void { ...@@ -40,6 +40,10 @@ public function testValidation(): void {
        $this->installConfig('system'); $this->installConfig('system');
        $this->assertCount(0, $data->validate()); $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());
        } }
        } }
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Finish editing this message first!
        Please register or to comment