Complex data constraint.
Validates properties of complex data structures.
@Plugin(
id = "ComplexData",
label = @Translation("Complex data", context = "Validation")
)
Expanded class hierarchy of ComplexDataConstraint
class ComplexDataConstraint extends Constraint {
/**
* 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 = array(
'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() {
return 'properties';
}
/**
* {@inheritdoc}
*/
public function getRequiredOptions() {
return array(
'properties',
);
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ComplexDataConstraint:: |
public | property | An array of constraints for contained properties, keyed by property name. | |
ComplexDataConstraint:: |
public | function |
Returns the name of the default option Overrides Constraint:: |
|
ComplexDataConstraint:: |
public | function |
Returns the name of the required options Overrides Constraint:: |
|
ComplexDataConstraint:: |
public | function |
Initializes the constraint with options. Overrides Constraint:: |
|
Constraint:: |
public | property | ||
Constraint:: |
public | function | Adds the given group if this constraint is in the Default group | |
Constraint:: |
constant | Marks a constraint that can be put onto classes | ||
Constraint:: |
constant | The name of the group given to all constraints with no explicit group | ||
Constraint:: |
public | function | Returns whether the constraint can be put onto classes, properties or both | 7 |
Constraint:: |
constant | Marks a constraint that can be put onto properties | ||
Constraint:: |
public | function | Returns the name of the class that validates this constraint | 2 |
Constraint:: |
public | function | Unsupported operation. |