Skip to content

Commit 8869480

Browse files
author
Michael Chiocca
committed
Optimize anyOf. Stop after first matched schema.
1 parent 2402bf5 commit 8869480

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/JsonSchema/Constraints/Undefined.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ protected function validateOfProperties($value, $schema, $path, $i)
202202
foreach ($schema->anyOf as $anyOf) {
203203
$initErrors = $this->getErrors();
204204
$this->checkUndefined($value, $anyOf, $path, $i);
205-
if (!$isValid) {
206-
$isValid = (count($this->getErrors()) == count($initErrors));
205+
if ($isValid = (count($this->getErrors()) == count($initErrors))) {
206+
break;
207207
}
208208
}
209209
if (!$isValid) {

0 commit comments

Comments
 (0)