Skip to content

Instantly share code, notes, and snippets.

@sebs
Created September 28, 2012 18:34
Show Gist options
  • Save sebs/3801420 to your computer and use it in GitHub Desktop.
Save sebs/3801420 to your computer and use it in GitHub Desktop.
validate a JSON with a JSON-Schema sent via POST
exports.validate = function(req, res){
// name of the schema to load schema from filesyste,
services.getSchema(req.params.name, function(err, schema) {
// validate me and in case has a length
amanda.validate(req.body, schema, function(error) {
if (error.length > 0) {
res.send(500, error);
return;
}
res.send(true);
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment