From 3ac99cd80f9691e63bde2e6915eff524f4b37a90 Mon Sep 17 00:00:00 2001 From: Bradley Whittington Date: Thu, 14 Sep 2017 16:21:18 +0200 Subject: [PATCH 1/3] Switch to just use the json serializable array of schema errors --- src/Validators/JSONSchemaEventValidator.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Validators/JSONSchemaEventValidator.php b/src/Validators/JSONSchemaEventValidator.php index 646b038..a76c08f 100644 --- a/src/Validators/JSONSchemaEventValidator.php +++ b/src/Validators/JSONSchemaEventValidator.php @@ -41,11 +41,7 @@ public function validate(EventInterface $event) if ($schemaValidator->passes()) { return new ValidationResult($this, $event, true); } else { - $errors = []; - foreach ($schemaValidator->errors() as $error) { - /* @var ValidationError $error */ - $errors[] = $error->getMessage(); - } + $errors = $schemaValidator->errors(); return new ValidationResult($this, $event, false, $errors); } } From 9b33c7bad1c4eae2a86fed5b2b238d3f5e8a95be Mon Sep 17 00:00:00 2001 From: Bradley Whittington Date: Thu, 14 Sep 2017 16:31:13 +0200 Subject: [PATCH 2/3] Fix test :troll: --- tests/Validators/JSONSchemaEventValidatorTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Validators/JSONSchemaEventValidatorTest.php b/tests/Validators/JSONSchemaEventValidatorTest.php index d805100..660fe40 100644 --- a/tests/Validators/JSONSchemaEventValidatorTest.php +++ b/tests/Validators/JSONSchemaEventValidatorTest.php @@ -58,8 +58,8 @@ public function testValidateWhenJsonIsInvalid() $this->assertFalse($result->passes()); $this->assertTrue($result->fails()); $this->assertEquals( - ['Required properties missing: ["user"]'], - $result->errors() + 'Required properties missing: ["user"]', + $result->errors()[0]->getMessage() ); } From 678b2b91e6e2a1a923c3e8f4287eae05c6278912 Mon Sep 17 00:00:00 2001 From: Bradley Whittington Date: Thu, 14 Sep 2017 16:53:27 +0200 Subject: [PATCH 3/3] Update changelog --- changelog.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 7205fa5..f02e1f1 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,9 @@ # Changelog +## 4.0.3 - 2017-07-20 + +* JSONValidator should just pass the json serializable validation result through + ## 4.0.2 - 2017-07-20 * Fix events not being validated correctly when attribute injectors are used @@ -35,4 +39,4 @@ ## 1.0.0 - 2017-01-27 -* Initial release \ No newline at end of file +* Initial release