Skip to content
Pieter Hordijk edited this page Dec 31, 2018 · 3 revisions

TOC

ValidAttributes

Validates the input file (string of SVG file path) to contain only valid SVG attributes.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\File\Image\Type\Svg\ValidAttributes;

(new ValidAttributes())->validate('/path/to/an/svg/file.svg');

Failure reasons

  • Type.String when the input valid is not a string
  • FileSystem.File when the validated file does not exist
  • File.MimeType when the validated file does not have an SVG mime type
  • File.Image.Type.Svg.ValidAttributes when the validated file does not contain valid XML
  • File.Image.Type.Svg.ValidAttributes when the validated file contains invalid SVG attributes

ValidElements

Validates the input file (string of SVG file path) to contain only valid SVG attributes.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\File\Image\Type\Svg\ValidElements;

(new ValidElements())->validate('/path/to/an/svg/file.svg');

Failure reasons

  • Type.String when the input valid is not a string
  • FileSystem.File when the validated file does not exist
  • File.MimeType when the validated file does not have an SVG mime type
  • File.Image.Type.Svg.ValidElements when the validated file does not contain valid XML
  • File.Image.Type.Svg.ValidElements when the validated file contains invalid SVG elements

Bmp

Validates the input file (string of BMP file path) to be a valid BMP file.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\File\Image\Type\Bmp;

(new Bmp())->validate('/path/to/an/bmp/file.bmp

Failure reasons

  • Type.String when the input valid is not a string
  • FileSystem.File when the validated file does not exist
  • File.Image.Type.Bmp when the validated file is not a BMP file

Gif

Validates the input file (string of GIF file path) to be a valid GIF file.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\File\Image\Type\Gif;

(new Gif())->validate('/path/to/a/gif/file.gif');

Failure reasons

  • Type.String when the input valid is not a string
  • FileSystem.File when the validated file does not exist
  • File.MimeType when the validated file does not have a GIF mime type
  • File.Image.Type.Gif when the validated file is not a valid GIF file

Jpeg

Validates the input file (string of JPEG file path) to be a valid JPEG file.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\File\Image\Type\Jpeg;

(new Jpeg())->validate('/path/to/a/jpg/file.jpg');

Failure reasons

  • Type.String when the input valid is not a string
  • FileSystem.File when the validated file does not exist
  • File.MimeType when the validated file does not have a JPEG mime type
  • File.Image.Type.Jpeg when the validated file is not a valid JPEG file

Png

Validates the input file (string of PNG file path) to be a valid PNG file.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\File\Image\Type\Png;

(new Png())->validate('/path/to/a/png/file.png');

Failure reasons

  • Type.String when the input valid is not a string
  • FileSystem.File when the validated file does not exist
  • File.MimeType when the validated file does not have a PNG mime type
  • File.Image.Type.Png when the validated file is not a valid PNG file

Svg

Validates the input file (string of SVG file path) to be a valid SVG file.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\File\Image\Type\Svg;

(new Svg())->validate('/path/to/an/svg/file.svg');

Failure reasons

  • Type.String when the input valid is not a string
  • FileSystem.File when the validated file does not exist
  • File.MimeType when the validated file does not have an SVG mime type
  • File.Image.Type.Svg.ValidAttributes when the validated file does not contain valid XML
  • File.Image.Type.Svg.ValidAttributes when the validated file contains invalid SVG attributes
  • File.Image.Type.Svg.ValidElements when the validated file does not contain valid XML
  • File.Image.Type.Svg.ValidElements when the validated file contains invalid SVG elements

AspectRatio

Validates the input file (string of file path) to have a specific aspect ratio as defined in the constructor (string {x}:{y}).

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\File\Image\AspectRatio;

(new AspectRatio('4:3'))->validate('/path/to/an/image.png');

Failure reasons

  • Type.String when the input valid is not a string
  • FileSystem.File when the validated file does not exist
  • File.Image.Image when the validated file is not an image
  • File.Image.AspectRatio when the image does not match the specific aspect ratio

Image

Validates the input file (string of file path) to have be an image.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\File\Image\Image;

(new Image())->validate('/path/to/an/image.png');

Failure reasons

  • Type.String when the input valid is not a string
  • FileSystem.File when the validated file does not exist
  • File.Image.Image when the validated file is not an image

Landscape

Validates the input file (string of file path) to be an image in landscape orientation.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\File\Image\Landscape;

(new Landscape())->validate('/path/to/an/image.png');

Failure reasons

  • Type.String when the input valid is not a string
  • FileSystem.File when the validated file does not exist
  • File.Image.Image when the validated file is not an image
  • File.Image.Landscape when the validated file does not have landscape orientation

MaximumHeight

Validates the input file (string of file path) to be an image smaller than or exactly maximum height (int).

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\File\Image\MaximumHeight;

(new MaximumHeight(200))->validate('/path/to/an/image.png');

Failure reasons

  • Type.String when the input valid is not a string
  • FileSystem.File when the validated file does not exist
  • File.Image.Image when the validated file is not an image
  • File.Image.MaximumHeight when the validated file is taller than the maximum height

MaximumWidth

Validates the input file (string of file path) to be an image smaller than or exactly maximum width (int).

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\File\Image\MaximumWidth;

(new MaximumWidth(400))->validate('/path/to/an/image.png');

Failure reasons

  • Type.String when the input valid is not a string
  • FileSystem.File when the validated file does not exist
  • File.Image.Image when the validated file is not an image
  • File.Image.MaximumWidth when the validated file is longer than the maximum width

MinimumHeight

Validates the input file (string of file path) to be an image larger than or exactly minimum height (int).

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\File\Image\MinimumHeight;

(new MinimumHeight(200))->validate('/path/to/an/image.png');

Failure reasons

  • Type.String when the input valid is not a string
  • FileSystem.File when the validated file does not exist
  • File.Image.Image when the validated file is not an image
  • File.Image.MinimumHeight when the validated file is smaller than the minimum height

MinimumWidth

Validates the input file (string of file path) to be an image larger than or exactly minimum width (int).

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\File\Image\MinimumWidth;

(new MinimumWidth(400))->validate('/path/to/an/image.png');

Failure reasons

  • Type.String when the input valid is not a string
  • FileSystem.File when the validated file does not exist
  • File.Image.Image when the validated file is not an image
  • File.Image.MinimumWidth when the validated file is smaller than the minimum width

Portrait

Validates the input file (string of file path) to be an image in portrait orientation.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\File\Image\Portrait;

(new Portrait())->validate('/path/to/an/image.png');

Failure reasons

  • Type.String when the input valid is not a string
  • FileSystem.File when the validated file does not exist
  • File.Image.Image when the validated file is not an image
  • File.Image.Portrait when the validated file does not have portrait orientation

Md5

Validates the input file (string of file path) to match the supplied hash (string).

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\File\Integrity\Md5;

(new Md5('13148717F8FAA9037F37D28971DFC219'))->validate('/path/to/a/file.txt');

Failure reasons

  • Type.String when the input valid is not a string
  • FileSystem.File when the validated file does not exist
  • File.Integrity.Md5 when the validated file does not match the supplied hash

Sha1

Validates the input file (string of file path) to match the supplied hash (string).

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\File\Integrity\Sha1;

(new Sha1('DD74D182C641E4C78502D863B44D0AEFF1575E54'))->validate('/path/to/a/file.txt');

Failure reasons

  • Type.String when the input valid is not a string
  • FileSystem.File when the validated file does not exist
  • File.Integrity.Sha1 when the validated file does not match the supplied hash

MaximumSize

Validates the input file (string of file path) to be smaller or exactly maximum size (int) in bytes.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\File\MaximumSize;

(new MaximumSize('1024'))->validate('/path/to/a/file.txt');

Failure reasons

  • Type.String when the input valid is not a string
  • FileSystem.File when the validated file does not exist
  • File.MaximumSize when the validated file is bigger than the maximum size

MimeType

Validates the input file (string of file path) to be of mime type (string).

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\File\MimeType;

(new MimeType('text/plain'))->validate('/path/to/a/file.txt');

Failure reasons

  • Type.String when the input valid is not a string
  • FileSystem.File when the validated file does not exist
  • File.MimeType when the validated file does not match the mime-type

MinimumSize

Validates the input file (string of file path) to be bigger or exactly minimum size (int) in bytes.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\File\MinimumSize;

(new MinimumSize('1024'))->validate('/path/to/a/file.txt');

Failure reasons

  • Type.String when the input valid is not a string
  • FileSystem.File when the validated file does not exist
  • File.MinimumSize when the validated file is smaller than the maximum size
Clone this wiki locally