-
Notifications
You must be signed in to change notification settings - Fork 2
File
- Image
- Integrity
- MaximumSize
- MimeType
- MinimumSize
Validates the input file (string of SVG file path) to contain only valid SVG attributes.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\File\Image\Type\Svg\ValidAttributes;
(new ValidAttributes())->validate('/path/to/an/svg/file.svg');-
Type.Stringwhen the input valid is not a string -
FileSystem.Filewhen the validated file does not exist -
File.MimeTypewhen the validated file does not have an SVG mime type -
File.Image.Type.Svg.ValidAttributeswhen the validated file does not contain valid XML -
File.Image.Type.Svg.ValidAttributeswhen the validated file contains invalid SVG attributes
Validates the input file (string of SVG file path) to contain only valid SVG attributes.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\File\Image\Type\Svg\ValidElements;
(new ValidElements())->validate('/path/to/an/svg/file.svg');-
Type.Stringwhen the input valid is not a string -
FileSystem.Filewhen the validated file does not exist -
File.MimeTypewhen the validated file does not have an SVG mime type -
File.Image.Type.Svg.ValidElementswhen the validated file does not contain valid XML -
File.Image.Type.Svg.ValidElementswhen the validated file contains invalid SVG elements
Validates the input file (string of BMP file path) to be a valid BMP file.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\File\Image\Type\Bmp;
(new Bmp())->validate('/path/to/an/bmp/file.bmp-
Type.Stringwhen the input valid is not a string -
FileSystem.Filewhen the validated file does not exist -
File.Image.Type.Bmpwhen the validated file is not a BMP file
Validates the input file (string of GIF file path) to be a valid GIF file.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\File\Image\Type\Gif;
(new Gif())->validate('/path/to/a/gif/file.gif');-
Type.Stringwhen the input valid is not a string -
FileSystem.Filewhen the validated file does not exist -
File.MimeTypewhen the validated file does not have a GIF mime type -
File.Image.Type.Gifwhen the validated file is not a valid GIF file
Validates the input file (string of JPEG file path) to be a valid JPEG file.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\File\Image\Type\Jpeg;
(new Jpeg())->validate('/path/to/a/jpg/file.jpg');-
Type.Stringwhen the input valid is not a string -
FileSystem.Filewhen the validated file does not exist -
File.MimeTypewhen the validated file does not have a JPEG mime type -
File.Image.Type.Jpegwhen the validated file is not a valid JPEG file
Validates the input file (string of PNG file path) to be a valid PNG file.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\File\Image\Type\Png;
(new Png())->validate('/path/to/a/png/file.png');-
Type.Stringwhen the input valid is not a string -
FileSystem.Filewhen the validated file does not exist -
File.MimeTypewhen the validated file does not have a PNG mime type -
File.Image.Type.Pngwhen the validated file is not a valid PNG file
Validates the input file (string of SVG file path) to be a valid SVG file.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\File\Image\Type\Svg;
(new Svg())->validate('/path/to/an/svg/file.svg');-
Type.Stringwhen the input valid is not a string -
FileSystem.Filewhen the validated file does not exist -
File.MimeTypewhen the validated file does not have an SVG mime type -
File.Image.Type.Svg.ValidAttributeswhen the validated file does not contain valid XML -
File.Image.Type.Svg.ValidAttributeswhen the validated file contains invalid SVG attributes -
File.Image.Type.Svg.ValidElementswhen the validated file does not contain valid XML -
File.Image.Type.Svg.ValidElementswhen the validated file contains invalid SVG elements
Validates the input file (string of file path) to have a specific aspect ratio as defined in the constructor (string {x}:{y}).
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\File\Image\AspectRatio;
(new AspectRatio('4:3'))->validate('/path/to/an/image.png');-
Type.Stringwhen the input valid is not a string -
FileSystem.Filewhen the validated file does not exist -
File.Image.Imagewhen the validated file is not an image -
File.Image.AspectRatiowhen the image does not match the specific aspect ratio
Validates the input file (string of file path) to have be an image.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\File\Image\Image;
(new Image())->validate('/path/to/an/image.png');-
Type.Stringwhen the input valid is not a string -
FileSystem.Filewhen the validated file does not exist -
File.Image.Imagewhen the validated file is not an image
Validates the input file (string of file path) to be an image in landscape orientation.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\File\Image\Landscape;
(new Landscape())->validate('/path/to/an/image.png');-
Type.Stringwhen the input valid is not a string -
FileSystem.Filewhen the validated file does not exist -
File.Image.Imagewhen the validated file is not an image -
File.Image.Landscapewhen the validated file does not have landscape orientation
Validates the input file (string of file path) to be an image smaller than or exactly maximum height (int).
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\File\Image\MaximumHeight;
(new MaximumHeight(200))->validate('/path/to/an/image.png');-
Type.Stringwhen the input valid is not a string -
FileSystem.Filewhen the validated file does not exist -
File.Image.Imagewhen the validated file is not an image -
File.Image.MaximumHeightwhen the validated file is taller than the maximum height
Validates the input file (string of file path) to be an image smaller than or exactly maximum width (int).
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\File\Image\MaximumWidth;
(new MaximumWidth(400))->validate('/path/to/an/image.png');-
Type.Stringwhen the input valid is not a string -
FileSystem.Filewhen the validated file does not exist -
File.Image.Imagewhen the validated file is not an image -
File.Image.MaximumWidthwhen the validated file is longer than the maximum width
Validates the input file (string of file path) to be an image larger than or exactly minimum height (int).
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\File\Image\MinimumHeight;
(new MinimumHeight(200))->validate('/path/to/an/image.png');-
Type.Stringwhen the input valid is not a string -
FileSystem.Filewhen the validated file does not exist -
File.Image.Imagewhen the validated file is not an image -
File.Image.MinimumHeightwhen the validated file is smaller than the minimum height
Validates the input file (string of file path) to be an image larger than or exactly minimum width (int).
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\File\Image\MinimumWidth;
(new MinimumWidth(400))->validate('/path/to/an/image.png');-
Type.Stringwhen the input valid is not a string -
FileSystem.Filewhen the validated file does not exist -
File.Image.Imagewhen the validated file is not an image -
File.Image.MinimumWidthwhen the validated file is smaller than the minimum width
Validates the input file (string of file path) to be an image in portrait orientation.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\File\Image\Portrait;
(new Portrait())->validate('/path/to/an/image.png');-
Type.Stringwhen the input valid is not a string -
FileSystem.Filewhen the validated file does not exist -
File.Image.Imagewhen the validated file is not an image -
File.Image.Portraitwhen the validated file does not have portrait orientation
Validates the input file (string of file path) to match the supplied hash (string).
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\File\Integrity\Md5;
(new Md5('13148717F8FAA9037F37D28971DFC219'))->validate('/path/to/a/file.txt');-
Type.Stringwhen the input valid is not a string -
FileSystem.Filewhen the validated file does not exist -
File.Integrity.Md5when the validated file does not match the supplied hash
Validates the input file (string of file path) to match the supplied hash (string).
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\File\Integrity\Sha1;
(new Sha1('DD74D182C641E4C78502D863B44D0AEFF1575E54'))->validate('/path/to/a/file.txt');-
Type.Stringwhen the input valid is not a string -
FileSystem.Filewhen the validated file does not exist -
File.Integrity.Sha1when the validated file does not match the supplied hash
Validates the input file (string of file path) to be smaller or exactly maximum size (int) in bytes.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\File\MaximumSize;
(new MaximumSize('1024'))->validate('/path/to/a/file.txt');-
Type.Stringwhen the input valid is not a string -
FileSystem.Filewhen the validated file does not exist -
File.MaximumSizewhen the validated file is bigger than the maximum size
Validates the input file (string of file path) to be of mime type (string).
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\File\MimeType;
(new MimeType('text/plain'))->validate('/path/to/a/file.txt');-
Type.Stringwhen the input valid is not a string -
FileSystem.Filewhen the validated file does not exist -
File.MimeTypewhen the validated file does not match the mime-type
Validates the input file (string of file path) to be bigger or exactly minimum size (int) in bytes.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\File\MinimumSize;
(new MinimumSize('1024'))->validate('/path/to/a/file.txt');-
Type.Stringwhen the input valid is not a string -
FileSystem.Filewhen the validated file does not exist -
File.MinimumSizewhen the validated file is smaller than the maximum size