-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Validator] Added option for specifying the size format for the File validator #10917
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
Conversation
Oh! And I'll make a doc PR asap |
Not sure I like to add yet another option for this. Why not choose one format (whatever it is) and document that we only support this one. That would be much better I think in the long run. |
Actually, there is a default format, which you may override. Both are alright I think. In any case, we don't want to change this at a later date. |
@@ -25,6 +25,7 @@ class File extends Constraint | |||
{ | |||
public $maxSize = null; | |||
public $mimeTypes = array(); | |||
public $sizeFormat = 'binary'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use the constant FileValidator::SIZE_FORMAT_BINARY
Should |
This lets someone choose between binary (multiples of 1024) and decimal (multiple of 1000) formats for specifying the size
Took @jeremy-derusse's feedback into account. |
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")
This lets someone choose between binary (multiples of 1024) and decimal (multiple of 1000) formats for specifying the size.
Example:
By default, the size format is in binary.