You are here

public function MachineName::getConstraints in Machine name 8

Gets a list of validation constraints.

Return value

array Array of constraints, each being an instance of \Symfony\Component\Validator\Constraint.

Overrides TypedData::getConstraints

File

src/Plugin/Field/FieldType/MachineName.php, line 64

Class

MachineName
Plugin implementation of the 'machine_name' field type.

Namespace

Drupal\machine_name\Plugin\Field\FieldType

Code

public function getConstraints() {
  $constraints = parent::getConstraints();
  $constraint_manager = $this
    ->getTypedDataManager()
    ->getValidationConstraintManager();
  $constraints[] = $constraint_manager
    ->create('MachineNameUnique', []);
  return $constraints;
}