Skip to content

Instantly share code, notes, and snippets.

@garyhodgson
Created January 31, 2013 22:59
Show Gist options
  • Save garyhodgson/4687493 to your computer and use it in GitHub Desktop.
Save garyhodgson/4687493 to your computer and use it in GitHub Desktop.
{
"type": "object",
"properties": {
"things": {
"type": "array",
"items": {
"type": "object",
"properties": {
"uuid": {
"type": "string",
"pattern": "[0-9A-Fa-f]{8}(-[0-9A-Fa-f]{4}){3}-[0-9A-Fa-f]{12}",
"required": true
},
"title": {
"type": "string",
"required": true
}
}
},
"required": true
}
}
}
var schema = require('js-schema');
var fs = require('fs');
var schematext = fs.readFileSync('schema.js-schema').toString()
var f = new Function("schema","return "+schematext)
var validate = f(schema);
console.log(validate.toJSON());
{ type: 'object',
properties: { things: { type: 'array', items: [Object], required: true } } }
schema({
"things" : Array.of({
"uuid": /[0-9A-Fa-f]{8}(-[0-9A-Fa-f]{4}){3}-[0-9A-Fa-f]{12}/,
"title": String,
}),
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment