Skip to content

Instantly share code, notes, and snippets.

@tomyan
Created August 6, 2010 10:35
Show Gist options
  • Save tomyan/511155 to your computer and use it in GitHub Desktop.
Save tomyan/511155 to your computer and use it in GitHub Desktop.
#!/usr/bin/node
var fs = require('fs');
var sys = require('sys');
var schema = fs.readFileSync(process.argv[2], 'utf8');
var json = fs.readFileSync(process.argv[3], 'utf8');
schema = JSON.parse(schema);
json = JSON.parse(json);
var JSV = require("./JSV/jsv").JSV;
var result = JSV.validate(json, schema);
var fail = result.errors.length > 0;
if (fail) {
sys.puts('\033[1;37;41mFAIL\033[m');
for (var i = 0, l = result.errors.length; i < l; i++) {
sys.puts(sys.inspect(result.errors[i]));
}
}
else {
sys.puts('\033[1;37;42mPASS\033[m');
} // green
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment