protected function validateArrayType($value, array $schema, array $types = []): ErrorResult
    {
        $result = new ErrorResult();
        if (is_array($value) === false || $this->isNumericallyIndexedArray($value) === false) {
            $result->addError($this->createError('type=array', 'type=' . gettype($value)));
            return $result;
        }

        if (isset($schema['minItems']) && count($value) < $schema['minItems']) {
            $result->addError($this->createError('minItems=' . $schema['minItems'], count($value) . ' items'));
        }

        if (isset($schema['maxItems']) && count($value) > $schema['maxItems']) {
            $result->addError($this->createError('maxItems=' . $schema['maxItems'], count($value) . ' items'));
        }

        if (isset($schema['items'])) {
            foreach ($value as $index => $itemValue) {
                $itemResult = $this->validate($itemValue, $schema['items'], $types);
                if ($itemResult->hasErrors()  === true) {
                    $result->forProperty('__index_' . $index)->merge($itemResult);
                }
            }
        }

        if (isset($schema['uniqueItems']) && $schema['uniqueItems'] === true) {
            $values = [];
            foreach ($value as $itemValue) {
                $itemHash = is_array($itemValue) ? serialize($itemValue) : $itemValue;
                if (in_array($itemHash, $values)) {
                    $result->addError($this->createError('Unique values are expected'));
                    break;
                }
                $values[] = $itemHash;
            }
        }

        return $result;
    }
protected function validateArrayType($value, array $schema, array $types = []): ErrorResult
    {
        $result = new ErrorResult();
        if (is_array($value) === false || $this->isNumericallyIndexedArray($value) === false) {
            $result->addError($this->createError('type=array', 'type=' . gettype($value)));
            return $result;
        }

        if (isset($schema['minItems']) && count($value) < $schema['minItems']) {
            $result->addError($this->createError('minItems=' . $schema['minItems'], count($value) . ' items'));
        }

        if (isset($schema['maxItems']) && count($value) > $schema['maxItems']) {
            $result->addError($this->createError('maxItems=' . $schema['maxItems'], count($value) . ' items'));
        }

        if (isset($schema['items'])) {
            foreach ($value as $index => $itemValue) {
                $itemResult = $this->validate($itemValue, $schema['items'], $types);
                if ($itemResult->hasErrors()  === true) {
                    $result->forProperty('__index_' . $index)->merge($itemResult);
                }
            }
        }

        if (isset($schema['uniqueItems']) && $schema['uniqueItems'] === true) {
            $values = [];
            foreach ($value as $itemValue) {
                $itemHash = is_array($itemValue) ? serialize($itemValue) : $itemValue;
                if (in_array($itemHash, $values)) {
                    $result->addError($this->createError('Unique values are expected'));
                    break;
                }
                $values[] = $itemHash;
            }
        }

        return $result;
    }
protected function validateArrayType ( $ value , array $ schema , array $ types = [ ] ) : ErrorResult { $ result = new ErrorResult ( ) ; if ( is_array ( $ value ) === false || $ this -> isNumericallyIndexedArray ( $ value ) === false ) { $ result -> addError ( $ this -> createError ( 'type=array' , 'type=' . gettype ( $ value ) ) ) ; return $ result ; } if ( isset ( $ schema [ 'minItems' ] ) && count ( $ value ) < $ schema [ 'minItems' ] ) { $ result -> addError ( $ this -> createError ( 'minItems=' . $ schema [ 'minItems' ] , count ( $ value ) . ' items' ) ) ; } if ( isset ( $ schema [ 'maxItems' ] ) && count ( $ value ) > $ schema [ 'maxItems' ] ) { $ result -> addError ( $ this -> createError ( 'maxItems=' . $ schema [ 'maxItems' ] , count ( $ value ) . ' items' ) ) ; } if ( isset ( $ schema [ 'items' ] ) ) { foreach ( $ value as $ index => $ itemValue ) { $ itemResult = $ this -> validate ( $ itemValue , $ schema [ 'items' ] , $ types ) ; if ( $ itemResult -> hasErrors ( ) === true ) { $ result -> forProperty ( '__index_' . $ index ) -> merge ( $ itemResult ) ; } } } if ( isset ( $ schema [ 'uniqueItems' ] ) && $ schema [ 'uniqueItems' ] === true ) { $ values = [ ] ; foreach ( $ value as $ itemValue ) { $ itemHash = is_array ( $ itemValue ) ? serialize ( $ itemValue ) : $ itemValue ; if ( in_array ( $ itemHash , $ values ) ) { $ result -> addError ( $ this -> createError ( 'Unique values are expected' ) ) ; break ; } $ values [ ] = $ itemHash ; } } return $ result ; }
Validate an array value with the given schema

The following properties are handled in given $schema:
- minItems : minimal allowed item Number
- maxItems : maximal allowed item Number
- items : schema for all instances of the array
- uniqueItems : allow only unique values

@param mixed $value
@param array $schema
@param array $types
@return ErrorResult
Validate an array value with the given schema