src/Actions/ObjectRecursiveValidator.php
protected static function validateValue($value, $field, $type)
    {

        switch ($type) {
            case RestorableInterface::TYPE_INTEGER:
                if (!is_int($value)) {
                    throw new InvalidPropertyException('Property value is not integer', 0, $field);
                }
                break;
            case RestorableInterface::TYPE_BOOLEAN:
                if (!is_bool($value)) {
                    throw new InvalidPropertyException('Property value is not boolean', 0, $field);
                }
                break;
            case RestorableInterface::TYPE_FLOAT:
                if (!is_float($value)) {
                    throw new InvalidPropertyException('Property value is not float', 0, $field);
                }
                break;
            case RestorableInterface::TYPE_STRING:
                if (!is_string($value)) {
                    throw new InvalidPropertyException('Property value is not string', 0, $field);
                }
                break;
            case RestorableInterface::TYPE_ARRAY:
                if (!is_array($value)) {
                    throw new InvalidPropertyException('Property value is not array', 0, $field);
                }
                break;
            case RestorableInterface::TYPE_DATE:
                if (!($value instanceof \DateTimeInterface)) {
                    throw new InvalidPropertyException('Property value is not date', 0, $field);
                }
                break;
            case $type instanceof AbstractCustomType:
                $type->validate($field);
                break;
            case is_array($type):
                if (empty($type) || count($type) > 1) {
                    throw new InvalidPropertyException('Incorrect array type. Please provide one element in array.');
                }

                $type = reset($type);

                foreach ((array)$value as $data) {
                    self::validateValue($data, $field, $type);
                }
                break;
            default:
                if ($value instanceof DataContainerInterface && is_subclass_of($type, DataContainerInterface::class)) {
                    self::validate($value);
                    break;
                }

                throw new InvalidPropertyTypeException('There is no provided type of property', 0, $field);
        }
    }
protected static function validateValue($value, $field, $type)
    {

        switch ($type) {
            case RestorableInterface::TYPE_INTEGER:
                if (!is_int($value)) {
                    throw new InvalidPropertyException('Property value is not integer', 0, $field);
                }
                break;
            case RestorableInterface::TYPE_BOOLEAN:
                if (!is_bool($value)) {
                    throw new InvalidPropertyException('Property value is not boolean', 0, $field);
                }
                break;
            case RestorableInterface::TYPE_FLOAT:
                if (!is_float($value)) {
                    throw new InvalidPropertyException('Property value is not float', 0, $field);
                }
                break;
            case RestorableInterface::TYPE_STRING:
                if (!is_string($value)) {
                    throw new InvalidPropertyException('Property value is not string', 0, $field);
                }
                break;
            case RestorableInterface::TYPE_ARRAY:
                if (!is_array($value)) {
                    throw new InvalidPropertyException('Property value is not array', 0, $field);
                }
                break;
            case RestorableInterface::TYPE_DATE:
                if (!($value instanceof \DateTimeInterface)) {
                    throw new InvalidPropertyException('Property value is not date', 0, $field);
                }
                break;
            case $type instanceof AbstractCustomType:
                $type->validate($field);
                break;
            case is_array($type):
                if (empty($type) || count($type) > 1) {
                    throw new InvalidPropertyException('Incorrect array type. Please provide one element in array.');
                }

                $type = reset($type);

                foreach ((array)$value as $data) {
                    self::validateValue($data, $field, $type);
                }
                break;
            default:
                if ($value instanceof DataContainerInterface && is_subclass_of($type, DataContainerInterface::class)) {
                    self::validate($value);
                    break;
                }

                throw new InvalidPropertyTypeException('There is no provided type of property', 0, $field);
        }
    }
@param mixed        $value
@param string       $field
@param string|array $type

@throws InvalidPropertyException
@throws InvalidPropertyTypeException
@throws BadGetterException