Method to check against the json schema

Signed-off-by: Fabio José <fabiojose@gmail.com>
This commit is contained in:
Fabio José 2019-10-29 14:03:09 -03:00
parent 09c34b4728
commit 07f27426f3
1 changed files with 11 additions and 0 deletions

View File

@ -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;