class UniqueFieldConstraint

Same name in other branches
  1. 9 core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/UniqueFieldConstraint.php \Drupal\Core\Validation\Plugin\Validation\Constraint\UniqueFieldConstraint
  2. 8.9.x core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/UniqueFieldConstraint.php \Drupal\Core\Validation\Plugin\Validation\Constraint\UniqueFieldConstraint
  3. 11.x core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/UniqueFieldConstraint.php \Drupal\Core\Validation\Plugin\Validation\Constraint\UniqueFieldConstraint

Checks if an entity field has a unique value.

Hierarchy

  • class \Drupal\Core\Validation\Plugin\Validation\Constraint\UniqueFieldConstraint extends \Symfony\Component\Validator\Constraint

Expanded class hierarchy of UniqueFieldConstraint

4 files declare their use of UniqueFieldConstraint
FileUriUnique.php in core/modules/file/src/Plugin/Validation/Constraint/FileUriUnique.php
StringItemTest.php in core/tests/Drupal/Tests/Core/Field/StringItemTest.php
UserMailUnique.php in core/modules/user/src/Plugin/Validation/Constraint/UserMailUnique.php
UserNameUnique.php in core/modules/user/src/Plugin/Validation/Constraint/UserNameUnique.php

File

core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/UniqueFieldConstraint.php, line 12

Namespace

Drupal\Core\Validation\Plugin\Validation\Constraint
View source
class UniqueFieldConstraint extends SymfonyConstraint {
    public $message = 'A @entity_type with @field_name %value already exists.';
    
    /**
     * This constraint is case-insensitive by default.
     *
     * For example "FOO" and "foo" would be considered as equivalent, and
     * validation of the constraint would fail.
     *
     * @var bool
     */
    public $caseSensitive = FALSE;
    
    /**
     * Returns the name of the class that validates this constraint.
     *
     * @return string
     */
    public function validatedBy() {
        return '\\Drupal\\Core\\Validation\\Plugin\\Validation\\Constraint\\UniqueFieldValueValidator';
    }

}

Members

Title Sort descending Modifiers Object type Summary Overrides
UniqueFieldConstraint::$caseSensitive public property This constraint is case-insensitive by default. 1
UniqueFieldConstraint::$message public property 3
UniqueFieldConstraint::validatedBy public function Returns the name of the class that validates this constraint. 1

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