2015-06-16 04:55:09 +02:00
|
|
|
# Size
|
|
|
|
|
2017-03-27 14:47:07 +02:00
|
|
|
- `Size(string $minSize)`
|
|
|
|
- `Size(string $minSize, string $maxSize)`
|
|
|
|
- `Size(null, string $maxSize)`
|
2015-06-16 04:55:09 +02:00
|
|
|
|
2019-03-04 13:04:25 +01:00
|
|
|
Validates whether the input is a file that is of a certain size or not.
|
2015-06-16 04:55:09 +02:00
|
|
|
|
|
|
|
```php
|
|
|
|
v::size('1KB')->validate($filename); // Must have at least 1KB size
|
|
|
|
v::size('1MB', '2MB')->validate($filename); // Must have the size between 1MB and 2MB
|
|
|
|
v::size(null, '1GB')->validate($filename); // Must not be greater than 1GB
|
|
|
|
```
|
|
|
|
|
|
|
|
Sizes are not case-sensitive and the accepted values are:
|
|
|
|
|
|
|
|
- B
|
|
|
|
- KB
|
|
|
|
- MB
|
|
|
|
- GB
|
|
|
|
- TB
|
|
|
|
- PB
|
|
|
|
- EB
|
|
|
|
- ZB
|
|
|
|
- YB
|
|
|
|
|
|
|
|
This validator will consider `SplFileInfo` instances, like:
|
|
|
|
|
|
|
|
```php
|
2019-03-04 13:04:25 +01:00
|
|
|
v::size('1.5mb')->validate(new SplFileInfo($filename)); // Will return true or false
|
2015-06-16 04:55:09 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
Message template for this validator includes `{{minSize}}` and `{{maxSize}}`.
|
|
|
|
|
2019-05-11 18:32:13 +02:00
|
|
|
## Categorization
|
|
|
|
|
|
|
|
- File system
|
|
|
|
|
2017-03-27 22:04:13 +02:00
|
|
|
## Changelog
|
|
|
|
|
|
|
|
Version | Description
|
|
|
|
--------|-------------
|
2019-06-06 22:09:12 +02:00
|
|
|
2.1.0 | Add PSR-7 support
|
2017-03-27 22:04:13 +02:00
|
|
|
1.0.0 | Created
|
|
|
|
|
2015-08-20 06:38:41 +02:00
|
|
|
***
|
2015-06-16 04:55:09 +02:00
|
|
|
See also:
|
|
|
|
|
2017-03-28 11:53:14 +02:00
|
|
|
- [Directory](Directory.md)
|
|
|
|
- [Executable](Executable.md)
|
|
|
|
- [Exists](Exists.md)
|
|
|
|
- [Extension](Extension.md)
|
|
|
|
- [File](File.md)
|
2018-12-11 13:31:50 +01:00
|
|
|
- [Image](Image.md)
|
2017-03-28 11:53:14 +02:00
|
|
|
- [Mimetype](Mimetype.md)
|
|
|
|
- [Readable](Readable.md)
|
|
|
|
- [SymbolicLink](SymbolicLink.md)
|
|
|
|
- [Uploaded](Uploaded.md)
|
|
|
|
- [Writable](Writable.md)
|