protected function checkItems($entity, $schema, $entityName)
    {
        if (isset($schema->items) && $schema->items) {
            // Item restriction is an array of schemas
            if (is_array($schema->items)) {
                foreach($entity as $index => $node) {
                    $nodeEntityName = $entityName . '[' . $index . ']';

                    // Check if the item passes any of the item validations
                    foreach($schema->items as $item) {
                        $nodeValid = true;
                        try {
                            $this->validateType($node, $item, $nodeEntityName);
                            // Pass
                            break;
                        } catch (ValidationException $e) {
                            $nodeValid = false;
                        }
                    }

                    // If item did not pass any item validations
                    if (!$nodeValid) {
                        $allowedTypes = array_map(function($item){
                            return $item->type == 'object' ? 'object (schema)' : $item->type;
                        }, $schema->items);
                        throw new ValidationException(sprintf('Invalid value for [%s], must be one of the following types: [%s]',
                            $nodeEntityName, implode(', ' , $allowedTypes)));
                    }
                }
            // Item restriction is a single schema
            } else if (is_object($schema->items)) {
                foreach($entity as $index => $node) {
                    $nodeEntityName = $entityName . '[' . $index . ']';
                    $this->validateType($node, $schema->items, $nodeEntityName);
                }

            } else {
                throw new SchemaException(sprintf('Invalid items value for [%s]', $entityName));
            }
        }

        return $this;
    }
protected function checkItems($entity, $schema, $entityName)
    {
        if (isset($schema->items) && $schema->items) {
            // Item restriction is an array of schemas
            if (is_array($schema->items)) {
                foreach($entity as $index => $node) {
                    $nodeEntityName = $entityName . '[' . $index . ']';

                    // Check if the item passes any of the item validations
                    foreach($schema->items as $item) {
                        $nodeValid = true;
                        try {
                            $this->validateType($node, $item, $nodeEntityName);
                            // Pass
                            break;
                        } catch (ValidationException $e) {
                            $nodeValid = false;
                        }
                    }

                    // If item did not pass any item validations
                    if (!$nodeValid) {
                        $allowedTypes = array_map(function($item){
                            return $item->type == 'object' ? 'object (schema)' : $item->type;
                        }, $schema->items);
                        throw new ValidationException(sprintf('Invalid value for [%s], must be one of the following types: [%s]',
                            $nodeEntityName, implode(', ' , $allowedTypes)));
                    }
                }
            // Item restriction is a single schema
            } else if (is_object($schema->items)) {
                foreach($entity as $index => $node) {
                    $nodeEntityName = $entityName . '[' . $index . ']';
                    $this->validateType($node, $schema->items, $nodeEntityName);
                }

            } else {
                throw new SchemaException(sprintf('Invalid items value for [%s]', $entityName));
            }
        }

        return $this;
    }
protected function checkItems ( $ entity , $ schema , $ entityName ) { if ( isset ( $ schema -> items ) && $ schema -> items ) { // Item restriction is an array of schemas if ( is_array ( $ schema -> items ) ) { foreach ( $ entity as $ index => $ node ) { $ nodeEntityName = $ entityName . '[' . $ index . ']' ; // Check if the item passes any of the item validations foreach ( $ schema -> items as $ item ) { $ nodeValid = true ; try { $ this -> validateType ( $ node , $ item , $ nodeEntityName ) ; // Pass break ; } catch ( ValidationException $ e ) { $ nodeValid = false ; } } // If item did not pass any item validations if ( ! $ nodeValid ) { $ allowedTypes = array_map ( function ( $ item ) { return $ item -> type == 'object' ? 'object (schema)' : $ item -> type ; } , $ schema -> items ) ; throw new ValidationException ( sprintf ( 'Invalid value for [%s], must be one of the following types: [%s]' , $ nodeEntityName , implode ( ', ' , $ allowedTypes ) ) ) ; } } // Item restriction is a single schema } else if ( is_object ( $ schema -> items ) ) { foreach ( $ entity as $ index => $ node ) { $ nodeEntityName = $ entityName . '[' . $ index . ']' ; $ this -> validateType ( $ node , $ schema -> items , $ nodeEntityName ) ; } } else { throw new SchemaException ( sprintf ( 'Invalid items value for [%s]' , $ entityName ) ) ; } } return $ this ; }
Check items restriction

@param array $entity
@param object $schema
@param string $entityName

@return Validator
Check items restriction