-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidatenavinfo.js
57 lines (51 loc) · 1.76 KB
/
validatenavinfo.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
var fs = require('fs');
var jjv = require('jjv');
var X3dJsonSchema = {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "JSON Schema X3D V3.3",
"description": "Development JSON Schema for X3D V3.3 ",
"type": "object",
"properties": {
"NavigationInfo": {
"type": "object",
"properties": {
"@type": {
"type": "array",
"minItems": 1,
"items": [
{
"type": "string",
"default": "EXAMINE"
},
{
"type": "string",
"default": "ANY"
}
],
"additionalItems": {
"type": "string"
}
}
},
"additionalProperties": false
}
}
};
var env = jjv();
env.addSchema('x3djson', X3dJsonSchema);
function validateJSON() {
var hello = {
"NavigationInfo": {
"@type": ["EXAMINE"]
}
};
var errors = env.validate('x3djson', hello);
if (!errors) {
console.log('jjv Valid');
} else {
console.log('jjv Validation failed.');
console.log('jjv Validation errors:');
console.log(JSON.stringify(errors));
}
}
validateJSON();