function EntityHasFieldConstraint::__construct

Attributes

#[HasNamedArguments]

File

core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityHasFieldConstraint.php, line 28

Class

EntityHasFieldConstraint
Checks if a value is an entity that has a specific field.

Namespace

Drupal\Core\Entity\Plugin\Validation\Constraint

Code

public function __construct(mixed $options = NULL, ?string $field_name = NULL, public $message = 'The entity must have the %field_name field.', public $notFieldableMessage = 'The entity does not support fields.', ?array $groups = NULL, mixed $payload = NULL) {
  parent::__construct($options, $groups, $payload);
  $this->field_name = $field_name ?? $this->field_name;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.