ex
Fork of mbed-os-example-mbed5-blinky by
dumi_doc-master/schema/vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/SchemaConstraint.php@44:c1d8923072ba, 2017-07-18 (annotated)
- Committer:
- TMBOY
- Date:
- Tue Jul 18 16:27:22 2017 +0800
- Revision:
- 44:c1d8923072ba
?
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| TMBOY | 44:c1d8923072ba | 1 | <?php |
| TMBOY | 44:c1d8923072ba | 2 | |
| TMBOY | 44:c1d8923072ba | 3 | /* |
| TMBOY | 44:c1d8923072ba | 4 | * This file is part of the JsonSchema package. |
| TMBOY | 44:c1d8923072ba | 5 | * |
| TMBOY | 44:c1d8923072ba | 6 | * For the full copyright and license information, please view the LICENSE |
| TMBOY | 44:c1d8923072ba | 7 | * file that was distributed with this source code. |
| TMBOY | 44:c1d8923072ba | 8 | */ |
| TMBOY | 44:c1d8923072ba | 9 | |
| TMBOY | 44:c1d8923072ba | 10 | namespace JsonSchema\Constraints; |
| TMBOY | 44:c1d8923072ba | 11 | |
| TMBOY | 44:c1d8923072ba | 12 | use JsonSchema\Exception\InvalidArgumentException; |
| TMBOY | 44:c1d8923072ba | 13 | use JsonSchema\Entity\JsonPointer; |
| TMBOY | 44:c1d8923072ba | 14 | |
| TMBOY | 44:c1d8923072ba | 15 | /** |
| TMBOY | 44:c1d8923072ba | 16 | * The SchemaConstraint Constraints, validates an element against a given schema |
| TMBOY | 44:c1d8923072ba | 17 | * |
| TMBOY | 44:c1d8923072ba | 18 | * @author Robert Schönthal <seroscho@googlemail.com> |
| TMBOY | 44:c1d8923072ba | 19 | * @author Bruno Prieto Reis <bruno.p.reis@gmail.com> |
| TMBOY | 44:c1d8923072ba | 20 | */ |
| TMBOY | 44:c1d8923072ba | 21 | class SchemaConstraint extends Constraint |
| TMBOY | 44:c1d8923072ba | 22 | { |
| TMBOY | 44:c1d8923072ba | 23 | /** |
| TMBOY | 44:c1d8923072ba | 24 | * {@inheritDoc} |
| TMBOY | 44:c1d8923072ba | 25 | */ |
| TMBOY | 44:c1d8923072ba | 26 | public function check($element, $schema = null, JsonPointer $path = null, $i = null) |
| TMBOY | 44:c1d8923072ba | 27 | { |
| TMBOY | 44:c1d8923072ba | 28 | if ($schema !== null) { |
| TMBOY | 44:c1d8923072ba | 29 | // passed schema |
| TMBOY | 44:c1d8923072ba | 30 | $this->checkUndefined($element, $schema, $path, $i); |
| TMBOY | 44:c1d8923072ba | 31 | } elseif ($this->getTypeCheck()->propertyExists($element, $this->inlineSchemaProperty)) { |
| TMBOY | 44:c1d8923072ba | 32 | $inlineSchema = $this->getTypeCheck()->propertyGet($element, $this->inlineSchemaProperty); |
| TMBOY | 44:c1d8923072ba | 33 | if (is_array($inlineSchema)) { |
| TMBOY | 44:c1d8923072ba | 34 | $inlineSchema = json_decode(json_encode($inlineSchema)); |
| TMBOY | 44:c1d8923072ba | 35 | } |
| TMBOY | 44:c1d8923072ba | 36 | // inline schema |
| TMBOY | 44:c1d8923072ba | 37 | $this->checkUndefined($element, $inlineSchema, $path, $i); |
| TMBOY | 44:c1d8923072ba | 38 | } else { |
| TMBOY | 44:c1d8923072ba | 39 | throw new InvalidArgumentException('no schema found to verify against'); |
| TMBOY | 44:c1d8923072ba | 40 | } |
| TMBOY | 44:c1d8923072ba | 41 | } |
| TMBOY | 44:c1d8923072ba | 42 | } |
