Skip to content

Commit 80638e7

Browse files
committed
feat: add support for $ref
1 parent 605fbec commit 80638e7

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/JsonSchema/Constraints/Drafts/Draft06/Draft06Constraint.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,19 @@
77
use JsonSchema\ConstraintError;
88
use JsonSchema\Constraints\Constraint;
99
use JsonSchema\Entity\JsonPointer;
10+
use JsonSchema\SchemaStorage;
11+
use JsonSchema\Uri\UriRetriever;
1012

1113
class Draft06Constraint extends Constraint
1214
{
13-
public function __construct()
15+
public function __construct(\JsonSchema\Constraints\Factory $factory = null)
1416
{
15-
parent::__construct(new Factory());
17+
18+
parent::__construct(new Factory(
19+
$factory ? $factory->getSchemaStorage() : new SchemaStorage(),
20+
$factory ? $factory->getUriRetriever() : new UriRetriever(),
21+
$factory ? $factory->getConfig() : Constraint::CHECK_MODE_NORMAL,
22+
));
1623
}
1724

1825
public function check(&$value, $schema = null, ?JsonPointer $path = null, $i = null): void
@@ -26,6 +33,7 @@ public function check(&$value, $schema = null, ?JsonPointer $path = null, $i = n
2633
}
2734

2835
// Apply defaults
36+
$this->checkForKeyword('ref', $value, $schema, $path, $i);
2937
$this->checkForKeyword('required', $value, $schema, $path, $i);
3038
$this->checkForKeyword('contains', $value, $schema, $path, $i);
3139
$this->checkForKeyword('properties', $value, $schema, $path, $i);

src/JsonSchema/Constraints/Drafts/Draft06/Factory.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,6 @@ class Factory extends \JsonSchema\Constraints\Factory
4141
'pattern' => PatternConstraint::class,
4242
'properties' => PropertiesConstraint::class,
4343
'items' => ItemsConstraint::class,
44+
'ref' => RefConstraint::class,
4445
];
4546
}

0 commit comments

Comments
 (0)