-
Notifications
You must be signed in to change notification settings - Fork 1
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.ArrayType
when 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.BooleanType
when 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.CallableType
when 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.FloatType
when 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.InstanceOfType
when the validated value is not an instance ofstring
type
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.IntegerType
when 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.IterableType
when 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.NullType
when 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.ObjectType
when 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.ResourceType
when 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.StringType
when the validated value is not astring