Skip to content

Commit

Permalink
Validierungs-Skript auf der Basis von Node.js hinzugefügt.
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Marienfeld committed Nov 13, 2012
1 parent 748ca6b commit f8fef72
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions validation/validate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// use with node.js
// install JSV:
// npm install JSV
var JSV = require("JSV").JSV;
var sys = require('sys');
var fs = require('fs');

var target_file = process.argv[2];

if (!target_file){
console.log("usage: node validate.js dataset.json")
}else{

fs.readFile('../OGPD_JSON_Schema.json',function(err,schema) {
if(err) throw err;
fs.readFile(target_file, function(err,data) {
if(err) throw err;
// Parse as JSON
var posts = JSON.parse(data);
var schemajs= JSON.parse(schema);
// Validate
var env = JSV.createEnvironment();
var report = env.validate(posts, schemajs);
// Echo to command line
console.log(target_file + ": " + report.errors.length + " error(s)");
if (report.errors.length > 0) {
console.log(report.errors);
}
});
});

}


0 comments on commit f8fef72

Please sign in to comment.