Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Collection.php

function Collection::initializeNestedConstraints

Overrides Composite::initializeNestedConstraints

File

vendor/symfony/validator/Constraints/Collection.php, line 58

Class

Collection
Validates a collection with constraints defined for specific keys.

Namespace

Symfony\Component\Validator\Constraints

Code

protected function initializeNestedConstraints() : void {
    parent::initializeNestedConstraints();
    foreach ($this->fields as $fieldName => $field) {
        // the XmlFileLoader and YamlFileLoader pass the field Optional
        // and Required constraint as an array with exactly one element
        if (\is_array($field) && 1 == \count($field)) {
            $this->fields[$fieldName] = $field = $field[0];
        }
        if (!$field instanceof Optional && !$field instanceof Required) {
            $this->fields[$fieldName] = new Required($field);
        }
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal