Skip to content

Commit c1097af

Browse files
committed
(#34): Try to fix json schema resolving logic
1 parent 67a892e commit c1097af

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/Validator/JustInRainbowJsonSchemaValidator.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,12 @@ public function validateOrFail(array $data, ?string $pathname = null): void
6565
*/
6666
private function validate(array $data): Validator
6767
{
68-
$validator = new Validator();
68+
$schema = \json_decode((string) \file_get_contents($this->jsonSchemaPathname));
69+
70+
assert(\is_object($schema), 'Schema must be an object');
6971

70-
$validator->validate($data, (object) [
71-
'$ref' => $this->jsonSchemaPathname,
72-
], Constraint::CHECK_MODE_TYPE_CAST);
72+
$validator = new Validator();
73+
$validator->validate($data, $schema, Constraint::CHECK_MODE_TYPE_CAST);
7374

7475
return $validator;
7576
}

0 commit comments

Comments
 (0)