diff --git a/lib/specs/spec_1.js b/lib/specs/spec_1.js index b3e7ee6..f9dcb73 100644 --- a/lib/specs/spec_1.js +++ b/lib/specs/spec_1.js @@ -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){ this.payload["id"] = _id; return this;