-
Notifications
You must be signed in to change notification settings - Fork 2
Type
Pieter Hordijk edited this page Jan 1, 2019
·
1 revision
- ArrayType
- BooleanType
- CallableType
- FloatType
- InstanceOfType
- IntegerType
- IterableType
- NullType
- ObjectType
- ResourceType
- StringType
Validates the input (mixed) to be an array.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Type\ArrayType;
(new ArrayType())->validate(['foo', 'bar']);-
Type.ArrayTypewhen the validated value is not an array
Validates the input (mixed) to be a bool.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Type\BooleanType;
(new BooleanType())->validate(true);-
Type.BooleanTypewhen the validated value is not a boolean
Validates the input (mixed) to be a callable.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Type\CallableType;
(new CallableType())->validate(function() {});-
Type.CallableTypewhen the validated value is not acallable
Validates the input (mixed) to be a float.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Type\FloatType;
(new FloatType())->validate('12.4');-
Type.FloatTypewhen the validated value is not afloat
Validates the input (mixed) to be an instance of string type.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Type\InstanceOfType;
(new InstanceOfType(\DateTimeInterface::class))->validate(\new DateTimeImmutable());-
Type.InstanceOfTypewhen the validated value is not an instance ofstringtype
Validates the input (mixed) to be an int.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Type\IntegerType;
(new IntegerType())->validate(10);-
Type.IntegerTypewhen the validated value is not anint
Validates the input (mixed) to be an iterable.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Type\IterableType;
(new IterableType())->validate(['foo']);-
Type.IterableTypewhen the validated value is not aniterable
Validates the input (mixed) to be NULL.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Type\NullType;
(new NullType())->validate(null);-
Type.NullTypewhen the validated value is notNULL
Validates the input (mixed) to be an object.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Type\ObjectType;
(new ObjectType())->validate(new \DateTimeImmutable());-
Type.ObjectTypewhen the validated value is not anobject
Validates the input (mixed) to be a resource.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Type\ResourceType;
(new ResourceType())->validate(fopen('/path/to/file', 'r'));-
Type.ResourceTypewhen the validated value is not aresource
Validates the input (mixed) to be a string.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Type\StringType;
(new StringType())->validate('A string');-
Type.StringTypewhen the validated value is not astring