jjv icon indicating copy to clipboard operation
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

Open coderextreme opened this issue 8 years ago • 2 comments

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();

coderextreme avatar Feb 24 '16 03:02 coderextreme

It could be how arrays are validated as well.

coderextreme avatar Feb 24 '16 03:02 coderextreme

2 other JSON validators pass this. I would like to know if they are wrong or not.

coderextreme avatar Feb 24 '16 03:02 coderextreme