FileNameLengthConstraint.php

Same filename and directory in other branches
  1. 10 core/modules/file/src/Plugin/Validation/Constraint/FileNameLengthConstraint.php
  2. 11.x core/modules/file/src/Plugin/Validation/Constraint/FileNameLengthConstraint.php

Namespace

Drupal\file\Plugin\Validation\Constraint

File

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

View source
<?php

namespace Drupal\file\Plugin\Validation\Constraint;

use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Validation\Attribute\Constraint;
use Symfony\Component\Validator\Attribute\HasNamedArguments;
use Symfony\Component\Validator\Constraint as SymfonyConstraint;

/**
 * File name length constraint.
 */
class FileNameLengthConstraint extends SymfonyConstraint {
  
  /**
   * The maximum file name length.
   *
   * @var int
   */
  public int $maxLength = 240;
  public function __construct(mixed $options = NULL, ?int $maxLength = NULL, public string $messageEmpty = "The file's name is empty. Enter a name for the file.", public string $messageTooLong = "The file's name exceeds the %maxLength characters limit. Rename the file and try again.", ?array $groups = NULL, mixed $payload = NULL) {
    parent::__construct($options, $groups, $payload);
    $this->maxLength = $maxLength ?? $this->maxLength;
  }

}

Classes

Title Deprecated Summary
FileNameLengthConstraint File name length constraint.

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