class ComplexDataConstraint
Same name in other branches
- 9 core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ComplexDataConstraint.php \Drupal\Core\Validation\Plugin\Validation\Constraint\ComplexDataConstraint
- 8.9.x core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ComplexDataConstraint.php \Drupal\Core\Validation\Plugin\Validation\Constraint\ComplexDataConstraint
- 10 core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ComplexDataConstraint.php \Drupal\Core\Validation\Plugin\Validation\Constraint\ComplexDataConstraint
Complex data constraint.
Validates properties of complex data structures.
Hierarchy
- class \Drupal\Core\Validation\Plugin\Validation\Constraint\ComplexDataConstraint extends \Symfony\Component\Validator\Constraint
Expanded class hierarchy of ComplexDataConstraint
File
-
core/
lib/ Drupal/ Core/ Validation/ Plugin/ Validation/ Constraint/ ComplexDataConstraint.php, line 14
Namespace
Drupal\Core\Validation\Plugin\Validation\ConstraintView source
class ComplexDataConstraint extends SymfonyConstraint {
/**
* An array of constraints for contained properties, keyed by property name.
*
* @var array
*/
public $properties;
/**
* {@inheritdoc}
*/
public function __construct($options = NULL) {
// Allow skipping the 'properties' key in the options.
if (is_array($options) && !array_key_exists('properties', $options)) {
$options = [
'properties' => $options,
];
}
parent::__construct($options);
$constraint_manager = \Drupal::service('validation.constraint');
// Instantiate constraint objects for array definitions.
foreach ($this->properties as &$constraints) {
foreach ($constraints as $id => $options) {
if (!is_object($options)) {
$constraints[$id] = $constraint_manager->create($id, $options);
}
}
}
}
/**
* {@inheritdoc}
*/
public function getDefaultOption() : ?string {
return 'properties';
}
/**
* {@inheritdoc}
*/
public function getRequiredOptions() : array {
return [
'properties',
];
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
ComplexDataConstraint::$properties | public | property | An array of constraints for contained properties, keyed by property name. |
ComplexDataConstraint::getDefaultOption | public | function | |
ComplexDataConstraint::getRequiredOptions | public | function | |
ComplexDataConstraint::__construct | public | function |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.