-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
File
validation size format is always in binary (IEC) format, ignoring the binaryFormat
option
#27682
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
Comments
The value
Since More generally, if the constraint is defined in binary format (KiB, MiB, GiB etc.) and the message is displayed in decimal format (kB, MB, GB), almost all the time, the unite used for display the value will be the byte due to the way how the value is formatted to be precise and readable. I'm not sure it's more legible but it will be more standardized. |
That's totally fine and I don't mind the rounding :)
I agree but isn't that the reason why the
Honestly, I'm not too sure whether I understand you correctly: Do you want to unify the unit being displayed in the error message to always show the same? |
…ording to binaryFormat option (jfredon) This PR was merged into the 2.8 branch. Discussion ---------- [FileValidator] Format file size in validation message according to binaryFormat option | Q | A | ------------- | --- | Branch? | 2.8 up to master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #27682 | License | MIT | Doc PR | The binaryFormat option of the constraint is not taken into account if the maxsize limit is defined by the php configuration files. This patch correct this inconsistent behavior. If the binaryOption is not set, the unit of measurement used remains in binary because it’s the unit used in php configuration files. Commits ------- 0edbbd3 Format file size in validation message according to binaryFormat option
Uh oh!
There was an error while loading. Please reload this page.
Symfony version(s) affected: 3.x, 4.x
Description
According to the docs, setting the
binaryFormat
option on theFile
validation constraint should report all sizes in the decimal (SI-prefixed, as in kB, MB, GB etc.) format. However, the sizes will still be reported in binary (IEC, as in KiB, MiB, GiB etc.) format, completely ignoring thebinaryFormat
configuration.By setting
binaryFormat=false
I'd expect thesuffix
to beMB
instead ofMiB
.Since the history of
megabyte
(MB) andmebibyte
(MiB) isn't already confusing enough, here's some additional reading material:How to reproduce
Given the following
php.ini
config:and the following validation code:
and the results looking something like:
Possible Solution
Make the reported size format depend on the
binaryFormat
option:The text was updated successfully, but these errors were encountered: