jjv
jjv copied to clipboard
Possible issue with @type from JSON document in schema ?? Not quite sure. I'm not sure why this JSON doesn't validate
var fs = require('fs'); var jjv = require('jjv');
var X3dJsonSchema = { "$schema": "http://json-schema.org/draft-04/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() { try { 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));
}
} catch (e) {
console.log('Failed JSON parse');
}
}
validateJSON();
It could be how arrays are validated as well.
2 other JSON validators pass this. I would like to know if they are wrong or not.