Skip to content

Instantly share code, notes, and snippets.

@sfentress
Created November 15, 2011 18:07
Show Gist options
  • Save sfentress/1367826 to your computer and use it in GitHub Desktop.
Save sfentress/1367826 to your computer and use it in GitHub Desktop.
var doc, env, report, schema;
schema = {
"paneSchema": {
"type": "object",
"properties": {
"height": {
"type": "number"
}
}
},
"properties": {
"topPane": {
"$ref": "#/paneSchema"
},
"bottomPane": {
"$ref": "#/paneSchema"
}
}
};
doc = {
"topPane": {
"height": 10
},
"bottomPane": {
"height": "not-a-number"
}
};
env = JSV.createEnvironment();
report = env.validate(doc, schema);
// ***** results in
[ { uri: 'urn:uuid:d7db063a-5232-4c3b-9d1b-8818ea1cda94#/properties/topPane',
schemaUri: 'http://json-schema.org/draft-03/hyper-schema#',
attribute: '{link:full}',
message: 'Unknown schema reference',
details: 'urn:uuid:d7db063a-5232-4c3b-9d1b-8818ea1cda94#/paneSchema' } ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment