Skip to content
This repository was archived by the owner on Jul 19, 2024. It is now read-only.

Commit 28ca107

Browse files
author
Bradley Whittington
authored
Merge pull request #6 from Superbalist/switch-to-error-arrays
Switch to just use the json serializable array of schema errors
2 parents 4d9c20c + 678b2b9 commit 28ca107

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

changelog.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 4.0.3 - 2017-07-20
4+
5+
* JSONValidator should just pass the json serializable validation result through
6+
37
## 4.0.2 - 2017-07-20
48

59
* Fix events not being validated correctly when attribute injectors are used
@@ -35,4 +39,4 @@
3539

3640
## 1.0.0 - 2017-01-27
3741

38-
* Initial release
42+
* Initial release

src/Validators/JSONSchemaEventValidator.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,7 @@ public function validate(EventInterface $event)
4141
if ($schemaValidator->passes()) {
4242
return new ValidationResult($this, $event, true);
4343
} else {
44-
$errors = [];
45-
foreach ($schemaValidator->errors() as $error) {
46-
/* @var ValidationError $error */
47-
$errors[] = $error->getMessage();
48-
}
44+
$errors = $schemaValidator->errors();
4945
return new ValidationResult($this, $event, false, $errors);
5046
}
5147
}

tests/Validators/JSONSchemaEventValidatorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ public function testValidateWhenJsonIsInvalid()
5858
$this->assertFalse($result->passes());
5959
$this->assertTrue($result->fails());
6060
$this->assertEquals(
61-
['Required properties missing: ["user"]'],
62-
$result->errors()
61+
'Required properties missing: ["user"]',
62+
$result->errors()[0]->getMessage()
6363
);
6464
}
6565

0 commit comments

Comments
 (0)