FileUriUnique.php

Same filename in other branches
  1. 9 core/modules/file/src/Plugin/Validation/Constraint/FileUriUnique.php
  2. 8.9.x core/modules/file/src/Plugin/Validation/Constraint/FileUriUnique.php
  3. 10 core/modules/file/src/Plugin/Validation/Constraint/FileUriUnique.php

Namespace

Drupal\file\Plugin\Validation\Constraint

File

core/modules/file/src/Plugin/Validation/Constraint/FileUriUnique.php

View source
<?php

namespace Drupal\file\Plugin\Validation\Constraint;

use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Validation\Attribute\Constraint;
use Drupal\Core\Validation\Plugin\Validation\Constraint\UniqueFieldConstraint;
use Drupal\Core\Validation\Plugin\Validation\Constraint\UniqueFieldValueValidator;

/**
 * Supports validating file URIs.
 */
class FileUriUnique extends UniqueFieldConstraint {
    public $message = 'The file %value already exists. Enter a unique file URI.';
    
    /**
     * This constraint is case-sensitive.
     *
     * For example "public://foo.txt" and "public://FOO.txt" are treated as
     * different values, and can co-exist.
     *
     * @var bool
     */
    public $caseSensitive = TRUE;
    
    /**
     * {@inheritdoc}
     */
    public function validatedBy() : string {
        return UniqueFieldValueValidator::class;
    }

}

Classes

Title Deprecated Summary
FileUriUnique Supports validating file URIs.

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