Skip to content
Pieter Hordijk edited this page Jan 1, 2019 · 1 revision

TOC

AlphaNumeric

Validates the input (string) to only contain alpha numeric characters.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\Text\AlphaNumeric;

(new AlphaNumeric())->validate('Lipsum 123');

Failure reasons

  • Type.String when the validated value is not a string
  • Text.AlphaNumeric when the validated value contains non alpha numeric characters

Ascii

Validates the input (string) to only contain ASCII characters.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\Text\Ascii;

(new Ascii())->validate('Lipsum 123');

Failure reasons

  • Type.String when the validated value is not a string
  • Text.Ascii when the validated value contains non ASCII characters

ByteLength

Validates the input (string) to be exactly bytes (int) long.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\Text\ByteLength;

(new ByteLength(6))->validate('Lipsum');

Failure reasons

  • Type.String when the validated value is not a string
  • Text.ByteLength when the validated is not exactly int bytes long

Length

Validates the input (string) to be exactly (int) UTF-8 characters long.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\Text\Length;

(new Length(6))->validate('€€');

Failure reasons

  • Type.String when the validated value is not a string
  • Text.Length when the validated value is not exactly int UTF-8 characters long

LengthRange

Validates the input (string) to be within the range of (int) minimum UTF-8 characters and (int) maximum UTF-8 characters.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\Text\LengthRange;

(new LengthRange(1, 10))->validate('€€');

Failure reasons

  • Type.String when the validated value is not a string
  • Text.MinimumLength when the validated value is shorter than int UTF-8 characters
  • Text.MaximumLength when the validated value is longer than int UTF-8 characters

MaximumLength

Validates the input (string) to be shorter than or exactly (int) maximum UTF-8 characters.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\Text\MaximumLength;

(new MaximumLength(10))->validate('€€');

Failure reasons

  • Type.String when the validated value is not a string
  • Text.MaximumLength when the validated value is longer than int UTF-8 characters

MinimumLength

Validates the input (string) to be longer than or exactly (int) minimum UTF-8 characters.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\Text\MinimumLength;

(new MinimumLength(1))->validate('€€');

Failure reasons

  • Type.String when the validated value is not a string
  • Text.MinimumLength when the validated value is shorter than int UTF-8 characters

NoControlCharacters

Validates the input (string) to not contain any control characters.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\Text\NoControlCharacters;

(new NoControlCharacters())->validate('Lipsum €€');

Failure reasons

  • Type.String when the validated value is not a string
  • Text.NoControlCharacters when the validated value contains control characters
Clone this wiki locally