blob: 6c44b834ff8571f941dc8746f94d3f53f9ea510c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#! /bin/env node
var validate = require('jsonschema').validate;
var fs = require('fs');
var readline = require('readline');
var schema = '';
var testCode = '';
var readline = require('readline');
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
});
rl.on('line', function(line){
fs.readFile('JSONSchema/schema.json', function(err, data) {
if (err) {
throw err;
}
schema = JSON.parse(data);
fs.readFile(line, function(err, data) {
if (err) {
throw err;
}
try {
testCode = JSON.parse(data);
} catch(e) {
console.log(e);
}
try {
var x = validate(testCode, schema);
if (x.errors.length > 0) {
console.log(line+':\n');
for (var i = 0; i < x.errors.length; i++) {
console.log(' '+x.errors[i]+'\n')
}
}
} catch(e) {
console.log(e);
}
});
});
});
|