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

Here's an example of an array that for some reason (bug?) that doesn't validate. #66

Open
coderextreme opened this issue Feb 24, 2016 · 0 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": {
"Extrusion": {
"type": "object",
"properties": {
"@crossSection": {
"type": "array",
"minItems": 4,
"items": [
{
"type": "number",
"default": 1
},
{
"type": "number",
"default": 1
},
{
"type": "number",
"default": 1
},
{
"type": "number",
"default": -1
},
{
"type": "number",
"default": -1
},
{
"type": "number",
"default": -1
},
{
"type": "number",
"default": -1
},
{
"type": "number",
"default": 1
},
{
"type": "number",
"default": 1
}
],
"additionalItems": {
"type": "number",
"default": 1
}
}
},
"additionalProperties": false
}
}
};

var env = jjv();
env.addSchema('x3djson', X3dJsonSchema);

function validateJSON() {
try {
var hello = { "Extrusion":
{
"@crossSection":[0,0,0.3,0,0.3,0.3,0,0.3]
}
};

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

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