Skip to content

Instantly share code, notes, and snippets.

@subkitio
Last active December 26, 2015 19:52
Show Gist options
  • Save subkitio/9427adee121567892f3f to your computer and use it in GitHub Desktop.
Save subkitio/9427adee121567892f3f to your computer and use it in GitHub Desktop.
HTTP Input Validation
const jsonSchema = require('json-schema');
var schema = {
"description" : "A geographical coordinate",
"type" : "object",
"properties" : {
"latitude" : { "type" : "number", "required":true },
"longitude" : { "type" : "number", "required":true }
}
};
var result = jsonSchema.validate({latitude: 0, longitude: 'string'}, schema);
res.send(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment