Skip to content

Commit 7677d78

Browse files
authored
Merge pull request #99 from liborm85/oneof-suberrors-fix
Fix missing sub errors in oneOf keyword
2 parents 699e894 + 1edcabb commit 7677d78

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Keywords/OneOfKeyword.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public function validate(ValidationContext $context, Schema $schema): ?Validatio
4848
$count = 0;
4949
$matchedIndex = -1;
5050
$object = $this->createArrayObject($context);
51+
$errors = [];
5152

5253
foreach ($this->value as $index => $value) {
5354
if ($value === false) {
@@ -70,7 +71,10 @@ public function validate(ValidationContext $context, Schema $schema): ?Validatio
7071
$value = $this->value[$index] = $context->loader()->loadObjectSchema($value);
7172
}
7273

73-
if (!$context->validateSchemaWithoutEvaluated($value, null, false, $object)) {
74+
$error = $context->validateSchemaWithoutEvaluated($value, null, false, $object);
75+
if ($error) {
76+
$errors[] = $error;
77+
} else {
7478
if (++$count > 1) {
7579
$this->addEvaluatedFromArrayObject($object, $context);
7680
return $this->error($schema, $context, 'oneOf', 'The data should match exactly one schema', [
@@ -89,6 +93,6 @@ public function validate(ValidationContext $context, Schema $schema): ?Validatio
8993

9094
return $this->error($schema, $context, 'oneOf', 'The data should match exactly one schema', [
9195
'matched' => [],
92-
]);
96+
], $errors);
9397
}
9498
}

0 commit comments

Comments
 (0)