Method to check against the json schema
Signed-off-by: Fabio José <fabiojose@gmail.com>
This commit is contained in:
parent
09c34b4728
commit
07f27426f3
|
@ -66,6 +66,17 @@ function Spec1(_caller) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check the spec constraints
|
||||||
|
*/
|
||||||
|
Spec1.prototype.check = function(ce){
|
||||||
|
var toCheck = (!ce ? this.payload : ce);
|
||||||
|
|
||||||
|
if(!isValidAgainstSchema(toCheck)) {
|
||||||
|
throw {message: "invalid payload", errors: isValidAgainstSchema.errors};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Spec1.prototype.id = function(_id){
|
Spec1.prototype.id = function(_id){
|
||||||
this.payload["id"] = _id;
|
this.payload["id"] = _id;
|
||||||
return this;
|
return this;
|
||||||
|
|
Loading…
Reference in New Issue