Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Validator] Add the option filenameMaxLength to the File constraint #49417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 22, 2023

Conversation

ke20
Copy link

@ke20 ke20 commented Feb 17, 2023

Q A
Branch? 6.3
Bug fix? no
New feature? yes
Deprecations? no
Tickets Fix #49359
License MIT
Doc PR TODO symfony/symfony-docs#...

This option allow to define a max length for the uploaded file:

// 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;
}

@carsonbot carsonbot added this to the 6.3 milestone Feb 17, 2023
@carsonbot carsonbot changed the title Add the option filenameMaxLength to the File constraint [Validator] Add the option filenameMaxLength to the File constraint Feb 17, 2023
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please have a look at test failures

@ke20 ke20 force-pushed the maxlengthfilename-option branch 2 times, most recently from 3b377a6 to c2b6ef4 Compare February 17, 2023 13:26
@ke20
Copy link
Author

ke20 commented Feb 17, 2023

please have a look at test failures

I fixed all tests for the component Validator, but it seems to have some tests in failure for the others components.

@Arman-Hosseini
Copy link
Contributor

@ke20 we are talking about file. So what do you think about using nameMaxLength instead of filenameMaxLength?

@ke20 ke20 force-pushed the maxlengthfilename-option branch 2 times, most recently from ea93c16 to c3aaf11 Compare February 21, 2023 08:19
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nitpicking and good to go on my side.

@nicolas-grekas nicolas-grekas force-pushed the maxlengthfilename-option branch from c3aaf11 to 107a6a3 Compare February 22, 2023 11:00
@nicolas-grekas
Copy link
Member

Thank you @ke20.

@ke20
Copy link
Author

ke20 commented Feb 22, 2023

Thank you @ke20.

Sorry I didn't have the time to fix the last little errors ... Thank you for your update !

nicolas-grekas added a commit that referenced this pull request Mar 17, 2023
… validator option (xabbuh)

This PR was merged into the 5.4 branch.

Discussion
----------

[Validator] add translations for the filename max length validator option

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | related to #49417
| License       | MIT
| Doc PR        |

Commits
-------

37ef83b add translations for the filename max length validator option
@fabpot fabpot mentioned this pull request May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Validator] Add an option to set a filename length limit
6 participants