Skip to content

Instantly share code, notes, and snippets.

@Sembiance
Created October 22, 2012 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sembiance/3931808 to your computer and use it in GitHub Desktop.
Save Sembiance/3931808 to your computer and use it in GitHub Desktop.
Sample JSON validation
var jsonSchema = require("json-schema");
var mySchema = { name : "test", type : "object", additionalProperties : false, properties : { fullName: { type : "string" } } };
var myObject = { fullName : "John Doe" };
var schemaResult = jsonSchema.validate(myObject, mySchema);
if(!schemaResult.valid)
return schemaResult.errors;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment