-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
30 lines (24 loc) · 1019 Bytes
/
index.js
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
Ajv = require('ajv');
async function test(){
let schemaDual = require('./data/schemas/dual.json');
let schemaDualCond = require('./data/schemas/dual-conditional.json');
let schemaSingle = require('./data/schemas/single.json');
let testFile = require('./data/to_validate/test.json');
const ajv = new Ajv();
validatorDual = ajv.compile(schemaDual);
validatorDualCond = ajv.compile(schemaDualCond);
validatorSingle = ajv.compile(schemaSingle);
validatorDual(testFile);
validatorDualCond(testFile);
validatorSingle(testFile);
validatorSingle.errors.forEach(error => {
console.log("Error for single schema: ", error.instancePath, " ", error.message)
});
validatorDual.errors.forEach(error => {
console.log("Error for dual schema: ", error.instancePath, " ", error.message)
});
validatorDualCond.errors.forEach(error => {
console.log("Error for dual conditional schema: ", error.instancePath, " ", error.message)
});
}
test();