FileExtensionConstraint.php

Same filename in other branches
  1. 11.x core/modules/file/src/Plugin/Validation/Constraint/FileExtensionConstraint.php

Namespace

Drupal\file\Plugin\Validation\Constraint

File

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

View source
<?php

declare (strict_types=1);
namespace Drupal\file\Plugin\Validation\Constraint;

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

/**
 * File extension constraint.
 */
class FileExtensionConstraint extends SymfonyConstraint {
    
    /**
     * The error message.
     *
     * @var string
     */
    public string $message = 'Only files with the following extensions are allowed: %files-allowed.';
    
    /**
     * The allowed file extensions.
     *
     * @var string
     */
    public string $extensions;
    
    /**
     * {@inheritdoc}
     */
    public function getDefaultOption() : string {
        return 'extensions';
    }

}

Classes

Title Deprecated Summary
FileExtensionConstraint File extension constraint.

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