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

Breadcrumb

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

class Constraint

Same name in this branch
  1. 11.1.x vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php \PHPUnit\Framework\Constraint\Constraint
  2. 11.1.x vendor/composer/semver/src/Constraint/Constraint.php \Composer\Semver\Constraint\Constraint
  3. 11.1.x vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Constraint.php \JsonSchema\Constraints\Constraint
  4. 11.1.x vendor/symfony/validator/Constraint.php \Symfony\Component\Validator\Constraint
  5. 11.1.x core/lib/Drupal/Core/Validation/Annotation/Constraint.php \Drupal\Core\Validation\Annotation\Constraint
  6. 11.1.x 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

Expanded class hierarchy of Constraint

See also

\Drupal\Core\Validation\ConstraintManager

\Symfony\Component\Validator\Constraint

hook_validation_constraint_alter()

Plugin API

77 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
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
CKEditor5MediaAndFilterSettingsInSyncConstraint.php in core/modules/ckeditor5/src/Plugin/Validation/Constraint/CKEditor5MediaAndFilterSettingsInSyncConstraint.php

... See full list

2 string references to 'Constraint'
Problem::getMissingPackageReason in vendor/composer/composer/src/Composer/DependencyResolver/Problem.php
@internal
RuleReasonDataReturnTypeExtension::getTypeFromMethodCall in vendor/composer/composer/src/Composer/PHPStan/RuleReasonDataReturnTypeExtension.php

File

core/lib/Drupal/Core/Validation/Attribute/Constraint.php, line 21

Namespace

Drupal\Core\Validation\Attribute
View 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
RSS feed
Powered by Drupal