MapContextDefinition not properly setting property definitions for validation

Created on 20 September 2025, 22 days ago

Problem/Motivation

The \Drupal\tool\TypedData\MapContextDefinition::getDataDefinition() method isn't properly taking advance of the map data types property definitions.

Steps to reproduce

 $test = new MapContextDefinition(
      data_type: 'map',
      required: TRUE,
      multiple: TRUE,
      value_definitions: [
        'value1' => new ContextDefinition(
          data_type: 'string',
          label: $this->t('Value 1'),
          required: TRUE
        ),
        'value2' => new ContextDefinition(
          data_type: 'integer',
          label: $this->t('Value 2'),
          required: TRUE
        ),
      ]
    );
    $context = new Context($test, [['value1' => null, 'value2' => 3]]);
    $violations = $context->validate();

Proposed resolution

Fix.

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States michaellander

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024