Skip to content

Instantly share code, notes, and snippets.

@sfentress
Created November 16, 2011 12:41
Show Gist options
  • Save sfentress/1369981 to your computer and use it in GitHub Desktop.
Save sfentress/1369981 to your computer and use it in GitHub Desktop.
schema = {
"properties": {
"topPane": {
"$ref": "paneSchema" // referring directly by a new id, not #/paneSchema
},
"bottomPane": {
"$ref": "paneSchema"
}
},
"paneSchema": {
"properties": {
"height": {
"type": "number"
}
}
}
};
doc = {
"topPane": {
"height": 10
},
"bottomPane": {
"height": "not-a-number"
}
};
env = JSV.createEnvironment();
env.createSchema(schema.paneSchema, schema, "paneSchema"); // this is the key
report = env.validate(doc, schema);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment