Conditions | 3 |
Paths | 3 |
Total Lines | 23 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
7 | public function validate_json( |
||
8 | $json, |
||
9 | $schemas_name, |
||
10 | $schemas_path) |
||
11 | { |
||
12 | $retriever = new JsonSchema\Uri\UriRetriever; |
||
13 | $json_schemas = $retriever->retrieve('file://' . $schemas_path . "/$schemas_name"); |
||
14 | |||
15 | $refResolver = new JsonSchema\RefResolver($retriever); |
||
16 | $refResolver->resolve($json_schemas, 'file://' . $schemas_path . "/"); |
||
17 | |||
18 | $validator = new JsonSchema\Validator(); |
||
19 | $validator->check($json, $json_schemas); |
||
20 | |||
21 | if ($validator->isValid()) |
||
22 | return false; |
||
23 | |||
24 | $details = ""; |
||
25 | foreach ($validator->getErrors() as $error) |
||
26 | $details .= sprintf("[%s] %s\n", $error['property'], $error['message']); |
||
27 | |||
28 | return $details; |
||
29 | } |
||
30 | } |