Permalink
Browse files

Continued work on JSON schema validation

  • Loading branch information...
1 parent 8d95661 commit f536ccfcfd579fe56f256f2ecb610b8f410828c0 @benkeen committed Jan 16, 2015
Showing with 560 additions and 776 deletions.
  1. +1 −0 api/index.html
  2. +0 −4 index.php
  3. +1 −1 library.php
  4. +5 −6 resources/classes/API.class.php
  5. +0 −765 resources/libs/json_validator/Validator.php
  6. +553 −0 resources/libs/jsv4.php
View
@@ -0,0 +1 @@
+<html><head></head><body></body></html>
View
@@ -58,8 +58,4 @@
$pageParams["accountType"] = "";
}
-//$dataTypes = DataTypePluginHelper::getDataTypeList(Core::$dataTypePlugins);
-//$schemaFiles = DataTypePluginHelper::getSchemaFiles($dataTypes);
-//print_r($schemaFiles);
-
Templates::displayPage("resources/templates/index.tpl", $pageParams);
View
@@ -40,7 +40,7 @@
require_once(__DIR__ . "/resources/classes/Utils.class.php");
// External libs
-require_once(__DIR__ . "/resources/libs/json_validator/Validator.php");
+require_once(__DIR__ . "/resources/libs/jsv4.php");
require_once(__DIR__ . "/resources/libs/smarty/Smarty.class.php");
require_once(__DIR__ . "/resources/classes/SecureSmarty.class.php");
@@ -1,7 +1,5 @@
<?php
-use Json\Validator;
-
class GenerateDataAPI extends API
{
@@ -101,11 +99,12 @@ private function validateDataTypeSettings($json) {
if (property_exists($rows[$i], "settings") && array_key_exists($dataType, $schemaFiles)) {
- // assumption is the our own schema files are valid. However, this will fail if they're not
- //$validator = new Validator($schemaFiles[$dataType], "json");
+ // assumption is the our own schema files are valid
+ $schema = $schemaFiles[$dataType];
+ $json = $rows[$i]->settings;
+ $result = Jsv4::validate($json, $schema);
- //$result = $validator->validate($rows[$i]->settings);
- return json_decode($schemaFiles[$dataType]); // $schemaFiles[$dataType];
+ return json_decode($result);
}
}
}
Oops, something went wrong.

0 comments on commit f536ccf

Please sign in to comment.