Skip to content

Commit

Permalink
Continued work on JSON schema validation
Browse files Browse the repository at this point in the history
  • Loading branch information
benkeen committed Jan 16, 2015
1 parent 8d95661 commit f536ccf
Show file tree
Hide file tree
Showing 6 changed files with 560 additions and 776 deletions.
1 change: 1 addition & 0 deletions api/index.html
@@ -0,0 +1 @@
<html><head></head><body></body></html>
4 changes: 0 additions & 4 deletions index.php
Expand Up @@ -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);
2 changes: 1 addition & 1 deletion library.php
Expand Up @@ -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");

Expand Down
11 changes: 5 additions & 6 deletions resources/classes/API.class.php
@@ -1,7 +1,5 @@
<?php

use Json\Validator;


class GenerateDataAPI extends API
{
Expand Down Expand Up @@ -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);
}
}
}
Expand Down

0 comments on commit f536ccf

Please sign in to comment.