value = $value; $this->alwaysValid = $alwaysValid; if (is_array($value)) { $this->count = count($value); } $this->keyword = $keyword; $this->startIndex = $startIndex; } /** * @inheritDoc */ public function validate( \Opis\JsonSchema\ValidationContext $context, \Opis\JsonSchema\Schema $schema, ): ?ValidationError { if ($this->alwaysValid || $this->value === true) { if ($this->count === -1) { $context->markAllAsEvaluatedItems(); } else { $context->markCountAsEvaluatedItems($this->count); } return null; } $count = count($context->currentData()); if ($this->startIndex >= $count) { // Already validated by other keyword return null; } if ($this->value === false) { if ($count === 0) { return null; } return $this->error($schema, $context, $this->keyword, 'Array must be empty'); } if ($this->count >= 0) { $errors = $this->errorContainer($context->maxErrors()); $max = min($count, $this->count); $evaluated = []; for ($i = $this->startIndex; $i < $max; $i++) { if ($this->value[$i] === true) { $evaluated[] = $i; continue; } if ($this->value[$i] === false) { $context->addEvaluatedItems($evaluated); return $this->error($schema, $context, $this->keyword, "Array item at index {index} is not allowed", [ 'index' => $i, ]); } if (is_object($this->value[$i]) && !($this->value[$i] instanceof \Opis\JsonSchema\Schema)) { $this->value[$i] = $context->loader()->loadObjectSchema($this->value[$i]); } $context->pushDataPath($i); $error = $this->value[$i]->validate($context); $context->popDataPath(); if ($error) { $errors->add($error); if ($errors->isFull()) { break; } } else { $evaluated[] = $i; } } $context->addEvaluatedItems($evaluated); if ($errors->isEmpty()) { return null; } return $this->error($schema, $context, $this->keyword, 'Array items must match corresponding schemas', [], $errors); } if (is_object($this->value) && !($this->value instanceof \Opis\JsonSchema\Schema)) { $this->value = $context->loader()->loadObjectSchema($this->value); } $object = $this->createArrayObject($context); $error = $this->validateIterableData($schema, $this->value, $context, $this->indexes($this->startIndex, $count), $this->keyword, 'All array items must match schema', [], $object); if ($object && $object->count()) { $context->addEvaluatedItems($object->getArrayCopy()); } return $error; } /** * @param int $start * @param int $max * @return iterable|int[] */ protected function indexes(int $start, int $max): iterable { for ($i = $start; $i < $max; $i++) { yield $i; } } } __halt_compiler();----SIGNATURE:----TTCy6BaqwZfr30OfQhjR+A7ohOgNdq6RdFubaJXgeRLxZCSO3hsSy9DX/0EyCFraDnOUOQnetpjRF0Sh8JL030vRhwlDQ9+lNkqiNgGlFH9oBjBqpKR8SuEW8dJEwfEIHg/JtnVCtWnRQTh9NJsJ0shhMpJIJzo0uW9eLwYu+C50/ddnk/WP/iZWXXvno2oP2JzEKS4VTKunahF9duaGDwz7RH1m+yQfsbJi917QuMJfwUXozNc4W6NR46HakOKHJ4hpfCLhdGO/sg7vRRcTXNlVaQWekAj1mYi5IHmP1R6c5NT4xaJgGIy03NZ3VvGBQ33p3IqZhMofjZyr7Z1JzwO7r7wFxcxAS9pyRbhBvR+YrJBlrU+6XAQ5dnMsd58eIIVhmJqN0qMlWX9tkPxAkHwAaq6dCXVdoDsoIl/wl2v8VSjBstHTNIAc6pVbvO+6QmCbPhnGhyX3AsrtXwyYAq8V3bPOR3VBOXjp0vUvTue2J3t7rrFLuPmiIjaMZ+DyGErtaL3ge7SnpjmDFyI5bzrRX4NiLW8tNp20IHyD9CZM2DrcwB6QI/Xfhk4JIOez/+OzOUlnskC/H9scunqKjLG+wNICGS0Tdf8bH+9T1Nrnh7qMgctOQhb2CdZN9ppIfpbpETB9Ae8dHXnkN1mru1VbfvuI8WPznOWCJvBy6+8=----ATTACHMENT:----Njc1NzQ4ODI5NTA1MzY2IDY3NDY3NjU3NzIyNDAzMjQgMTI3MDc0NDIxMDUwMTA0MQ==