respect-validation/docs/rules/Size.md
Henrique Moody 52614d600d
Organize documentation for "Read the Docs"
The current documentation is hosted via GitHub pages rendered by
"Couscous". Every time we need a new version of the documentation
published we need to manually execute the "couscous".

This commit reorganize the documentation to be published to
"Read the Docs" because it will also allow us to have documentations per
version of the library most importantly provider a search field for the
documentation.

The documentation will be then published on:
https://respect-validation.readthedocs.io/

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-08-23 01:59:39 +02:00

1 KiB

Size

  • v::size(string $minSize)
  • v::size(string $minSize, string $maxSize)
  • v::size(null, string $maxSize)

Validates file sizes:

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:

$fileInfo = new SplFileInfo($filename);
v::size('1.5mb')->validate($fileInfo); // Will return true or false

Message template for this validator includes {{minSize}} and {{maxSize}}.


See also: