Skip to content

Commit 18c5ba1

Browse files
alexmmmsiwinski
authored andcommitted
fix Constraint::getErrors implementation
- remove presentation logic from implementation and dont filter returned errors by array_unique, business logic requires getErrors to return all existing errors, even if it contains duplicates - make Validator::getErrors() return the same filtered result as before and apply array_unique when setting errors on Validator instance
1 parent 77dc21b commit 18c5ba1

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/JsonSchema/Constraints/Constraint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function addErrors(array $errors)
8282
*/
8383
public function getErrors()
8484
{
85-
return array_unique($this->errors, SORT_REGULAR);
85+
return $this->errors;
8686
}
8787

8888
/**

src/JsonSchema/Validator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ public function check($value, $schema = null, $path = null, $i = null)
4040
$validator = new Schema($this->checkMode, $this->uriRetriever);
4141
$validator->check($value, $schema);
4242

43-
$this->addErrors($validator->getErrors());
43+
$this->addErrors(array_unique($validator->getErrors(), SORT_REGULAR));
4444
}
4545
}

0 commit comments

Comments
 (0)