3 namespace Drupal\Core\Entity\Plugin\Validation\Constraint;
5 use Symfony\Component\Validator\Constraint;
8 * Checks if a value is an entity that has a specific field.
11 * id = "EntityHasField",
12 * label = @Translation("Entity has field", context = "Validation"),
13 * type = { "entity" },
16 class EntityHasFieldConstraint extends Constraint {
19 * The default violation message.
23 public $message = 'The entity must have the %field_name field.';
26 * The violation message for non-fieldable entities.
30 public $notFieldableMessage = 'The entity does not support fields.';
33 * The field name option.
42 public function getDefaultOption() {
49 public function getRequiredOptions() {
50 return (array) $this->getDefaultOption();