class Constraint
Same name in this branch
- 11.x core/lib/Drupal/Core/Validation/Annotation/Constraint.php \Drupal\Core\Validation\Annotation\Constraint
- 11.x core/lib/Drupal/Component/Version/Constraint.php \Drupal\Component\Version\Constraint
Same name in other branches
- 9 core/lib/Drupal/Core/Validation/Annotation/Constraint.php \Drupal\Core\Validation\Annotation\Constraint
- 9 core/lib/Drupal/Component/Version/Constraint.php \Drupal\Component\Version\Constraint
- 8.9.x core/lib/Drupal/Core/Validation/Annotation/Constraint.php \Drupal\Core\Validation\Annotation\Constraint
- 8.9.x core/lib/Drupal/Component/Version/Constraint.php \Drupal\Component\Version\Constraint
- 10 core/lib/Drupal/Core/Validation/Attribute/Constraint.php \Drupal\Core\Validation\Attribute\Constraint
- 10 core/lib/Drupal/Core/Validation/Annotation/Constraint.php \Drupal\Core\Validation\Annotation\Constraint
- 10 core/lib/Drupal/Component/Version/Constraint.php \Drupal\Component\Version\Constraint
Defines a Constraint attribute object.
Plugin Namespace: Plugin\Validation\Constraint
For a working example, see \Drupal\Core\Validation\Plugin\Validation\Constraint\LengthConstraint
Hierarchy
- class \Drupal\Component\Plugin\Attribute\AttributeBase implements \Drupal\Component\Plugin\Attribute\AttributeInterface
- class \Drupal\Component\Plugin\Attribute\Plugin extends \Drupal\Component\Plugin\Attribute\AttributeBase
- class \Drupal\Core\Validation\Attribute\Constraint extends \Drupal\Component\Plugin\Attribute\Plugin
- class \Drupal\Component\Plugin\Attribute\Plugin extends \Drupal\Component\Plugin\Attribute\AttributeBase
Expanded class hierarchy of Constraint
See also
\Drupal\Core\Validation\ConstraintManager
\Symfony\Component\Validator\Constraint
hook_validation_constraint_alter()
88 files declare their use of Constraint
- AllowedValuesConstraint.php in core/
lib/ Drupal/ Core/ Validation/ Plugin/ Validation/ Constraint/ AllowedValuesConstraint.php - BlockContentEntityChangedConstraint.php in core/
modules/ block_content/ src/ Plugin/ Validation/ Constraint/ BlockContentEntityChangedConstraint.php - BookOutlineConstraint.php in core/
modules/ book/ src/ Plugin/ Validation/ Constraint/ BookOutlineConstraint.php - BundleConstraint.php in core/
lib/ Drupal/ Core/ Entity/ Plugin/ Validation/ Constraint/ BundleConstraint.php - CKEditor5ElementConstraint.php in core/
modules/ ckeditor5/ src/ Plugin/ Validation/ Constraint/ CKEditor5ElementConstraint.php
1 string reference to 'Constraint'
- DependencyTest::testSerialization in core/
tests/ Drupal/ Tests/ Core/ Extension/ DependencyTest.php - Ensures that constraint objects are not serialized.
File
-
core/
lib/ Drupal/ Core/ Validation/ Attribute/ Constraint.php, line 21
Namespace
Drupal\Core\Validation\AttributeView source
class Constraint extends Plugin {
/**
* Constructs a Constraint attribute.
*
* @param string $id
* The constraint plugin ID.
* @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $label
* (optional) The human-readable name of the constraint plugin.
* @param string|string[]|false $type
* (optional) DataType plugin IDs for which this constraint applies. Valid
* values are any types registered by the typed data API, or an array of
* multiple type names. For supporting all types, FALSE may be specified.
* The key defaults to an empty array, which indicates no types are
* supported.
* @param class-string|null $deriver
* (optional) The deriver class.
*/
public function __construct(string $id, ?TranslatableMarkup $label = NULL, string|array|false $type = [], ?string $deriver = NULL) {
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
AttributeBase::$class | protected | property | The class used for this attribute class. | ||
AttributeBase::$provider | protected | property | The provider of the attribute class. | ||
AttributeBase::get | public | function | Gets the value of an attribute. | Overrides AttributeInterface::get | 6 |
AttributeBase::getClass | public | function | Gets the class of the attribute class. | Overrides AttributeInterface::getClass | 1 |
AttributeBase::getId | public | function | Gets the unique ID for this attribute class. | Overrides AttributeInterface::getId | |
AttributeBase::getProvider | public | function | Gets the name of the provider of the attribute class. | Overrides AttributeInterface::getProvider | |
AttributeBase::setClass | public | function | Sets the class of the attributed class. | Overrides AttributeInterface::setClass | 1 |
AttributeBase::setProvider | public | function | Sets the name of the provider of the attribute class. | Overrides AttributeInterface::setProvider | |
Constraint::__construct | public | function | Constructs a Constraint attribute. | Overrides Plugin::__construct |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.