You are here

MachineNameUniqueConstraint.php in Machine name 8

File

src/Plugin/Validation/Constraint/MachineNameUniqueConstraint.php
View source
<?php

namespace Drupal\machine_name\Plugin\Validation\Constraint;

use Symfony\Component\Validator\Constraint;

/**
 * Checks if an entity field has a unique value.
 *
 * @Constraint(
 *   id = "MachineNameUnique",
 *   label = @Translation("Unique machine name constraint", context = "Validation"),
 * )
 */
class MachineNameUniqueConstraint extends Constraint {
  public $message = 'The machine name %value is already in use. It must be unique.';

  /**
   * {@inheritdoc}
   */
  public function validatedBy() {
    return '\\Drupal\\machine_name\\Plugin\\Validation\\Constraint\\MachineNameUniqueValidator';
  }

}

Classes

Namesort descending Description
MachineNameUniqueConstraint Checks if an entity field has a unique value.