Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible issue with @type from JSON document in schema ?? Not quite sure. I'm not sure why this JSON doesn't validate #65

Open
coderextreme opened this issue Feb 24, 2016 · 2 comments

Comments

@coderextreme
Copy link

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
Copy link
Author

It could be how arrays are validated as well.

@coderextreme
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant