Skip to content

Commit

Permalink
Add root path to Validator, to be able to use the draft-07.json from …
Browse files Browse the repository at this point in the history
…package
  • Loading branch information
bjoern-hempel committed Sep 16, 2023
1 parent 0cfbf1a commit 8ecffb6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion src/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function validate(): bool
$this->schema instanceof Json => $resolver->registerRaw($this->schema->getJsonStringFormatted(), Constants::ID_JSON_SCHEMA_GENERAL)
};

$resolver->registerFile(Constants::URL_JSON_SCHEMA_DRAFT_07, (new File(Constants::PATH_SCHEMA_DRAFT_07, $this->pathRoot))->getPathReal());
$resolver->registerFile(Constants::URL_JSON_SCHEMA_DRAFT_07, (new File(Constants::PATH_SCHEMA_DRAFT_07, $this->pathRoot ?: $this->getRootPath()))->getPathReal());

$data = match (true) {
$this->data instanceof File => $this->getJsonDecoded($this->data->getContentAsJson()->getJsonStringFormatted()),
Expand Down Expand Up @@ -231,4 +231,14 @@ public function getStatusJson(): string
{
return (new Json($this->getStatusArray()))->getJsonStringFormatted();
}

/**
* Returns the root path of this class.
*
* @return string
*/
private function getRootPath(): string
{
return dirname(__FILE__, 2);
}
}

0 comments on commit 8ecffb6

Please sign in to comment.