Skip to content

Instantly share code, notes, and snippets.

@supersheep
Created February 11, 2013 09:00
Show Gist options
  • Save supersheep/4753364 to your computer and use it in GitHub Desktop.
Save supersheep/4753364 to your computer and use it in GitHub Desktop.
function(resschema,body,type){
var result,schema;
if(!resschema){
return {ok:false,msg:"no response schema"};
}
if(!body){
return {ok:false,msg:"no body"};
}
try{
schema = eval("("+resschema+")");
}catch(e){
return {ok:false,msg:"[schema parse error]"+e}
}
return Schema(schema)(body) ? {ok:true,msg:"tada!"} : {ok:false,msg:"body doesn't match schema"};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment