-
Notifications
You must be signed in to change notification settings - Fork 0
/
validateimage.js
66 lines (60 loc) · 1.71 KB
/
validateimage.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
58
59
60
61
62
63
64
65
66
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": "Experimental JSON Schema for X3D V3.3 ",
"type": "object",
"properties": {
"PixelTexture": {
"type": "object",
"properties": {
"@image": {
"type": "array",
"minItems": 3,
"items": [
{
"type": "integer",
"default": 0
},
{
"type": "integer",
"default": 0
},
{
"type": "integer",
"default": 0
}
],
"additionalItems": {
"type": "integer"
}
}
}
}
}
};
var env = jjv();
env.addSchema('x3djson', X3dJsonSchema);
function validateJSON() {
try {
var hello =
{ "PixelTexture":
{
"@image":[3,2,4,4278190335,16711935,65535,4278190207,16711807,65407]
}
}
;
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));
}
} catch (e) {
console.log('Failed JSON parse');
}
}
validateJSON();