Skip to content

Primitives

use Innmind\Validation\Is;

$validate = Is::string();
use Innmind\Validation\Is;

$validate = Is::int();
use Innmind\Validation\Is;

$validate = Is::float();
use Innmind\Validation\Is;

$validate = Is::array();
use Innmind\Validation\Is;

$validate = Is::bool();
use Innmind\Validation\Is;

$validate = Is::null();

By default the error message will be Value is not of type {primitive}. You can change it via:

$validate = Is::string()->withFailure('Some error message');

Lists

This constraint validates the input is an array and all values are consecutive (1).

  1. No index value specified, be it ints or strings.
use Innmind\Validation\Is;

$validate = Is::list();

You can also validate that each value in the list is of a given type. Here's how to validate a list os strings:

use Innmind\Validation\Is;

$validate = Is::list(Is::string());