Created
January 31, 2013 22:59
-
-
Save garyhodgson/4687493 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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 | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ type: 'object', | |
properties: { things: { type: 'array', items: [Object], required: true } } } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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