-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
[Validator] Support "maxSize" given in KiB #10962
Comments
The validation message suffix should also depend on the setting. |
This PR was merged into the 2.5-dev branch. Discussion ---------- Made use of "kB" vs. "KiB" consistent | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Continuation of #10661. This PR makes the usage of "kB" and "KiB" consistent across the project. The notations equal the internationally recognized ones: Short form | Long form | Value in Bytes --- | --- | --- B | bytes | 1 kB | kilobytes | 1000 KiB | kibibytes | 1024 MB | megabytes | 1000000 MiB | mebibytes | 1048576 GB | gigabytes | 1000000000 GiB | gibibytes | 1073741824 The reason for differentiating between the two is that several users got confused with the current mix (see #10648, #10917, #10661). FileValidator, UploadedFile and the ProgressBar helper were changed accordingly. Follow-up feature request: #10962 Commits ------- e4c6da5 [Validator] Improved to-string conversion of the file size/size limit bbe1045 [Validator][Console][HttpFoundation] Use "KiB" everywhere (instead of "kB")
There is a lot of dupplicate code in Symfony about the convertion bytes <-> humanized :
I thinks, we should provide a class responsible for managing those conversions. |
The duplication was done on purpose. The only way to factor out this code would be to create a new component, but I don't think it is worth it. |
…ussé) This PR was squashed before being merged into the 2.6-dev branch (closes #11027). Discussion ---------- [Validator] Support "maxSize" given in KiB | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #10962 | License | MIT | Doc PR | symfony/symfony-docs#3895 To display the constraint validation message with an expected suffix, this PR add a new option in File constraint. Commits ------- 48ed754 [Validator] Support "maxSize" given in KiB
…sse) This PR was merged into the master branch. Discussion ---------- [Validator] Support "maxSize" given in KiB | Q | A | ------------- | --- | Doc fix? | no | New docs? | symfony/symfony#11027 | Applies to | 2.6 | Fixed tickets | symfony/symfony#10962 To display the constraint validation message with an expected suffix, this PR add a new option in File constraint. Commits ------- 1e8fa48 Replace bullet list by a table 77a0687 Add versionAdded on binary suffix b414f5c Use comma as thousands separator 7dcd7c3 Move secion "binaryFormat" to the right place 71fdd60 Fix line wrap 3f3f4e0 Provide information about SI and Binary prefixes deac0c3 Add option binaryFormat in constraint file e3acdc5 Support MaxSize in KiB and MiB
The
File
constraint should support the following notations for the "maxSize" option:The conversion of the passed value to the number of bytes should be done already in the constructor of
File
, to simplify dealing with the file constraint:The text was updated successfully, but these errors were encountered: