Skip to content

[Validator] Add an option to set a filename length limit  #49359

@ke20

Description

@ke20

Description

On this owasp page we can see Set a filename length limit. Restrict the allowed characters if possible.

I could be interesting to add an option in the File Constraint to check that ?

If yes, I can create a MR for that.

Example

For example we can have :

// src/Entity/Author.php
namespace App\Entity;

use Symfony\Component\Validator\Constraints as Assert;

class Author
{
    #[Assert\File(
        maxSize: '1024k',
        filenameMaxLength: 50,
        filenameMaxLengthMessage: 'The filename is too long. It should have 50 character or less.'
    )]
    protected $bioFile;
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions