Skip to content

Commit 50e54bc

Browse files
committed
Fix missing sub errors in oneOf keyword
1 parent 1cec9a5 commit 50e54bc

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Keywords/OneOfKeyword.php

Lines changed: 7 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,11 @@ 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+
}
78+
if (!$error) {
7479
if (++$count > 1) {
7580
$this->addEvaluatedFromArrayObject($object, $context);
7681
return $this->error($schema, $context, 'oneOf', 'The data should match exactly one schema', [
@@ -89,6 +94,6 @@ public function validate(ValidationContext $context, Schema $schema): ?Validatio
8994

9095
return $this->error($schema, $context, 'oneOf', 'The data should match exactly one schema', [
9196
'matched' => [],
92-
]);
97+
], $errors);
9398
}
9499
}

0 commit comments

Comments
 (0)