Remove the responsability of spec checking

Signed-off-by: Fabio José <fabiojose@gmail.com>
This commit is contained in:
Fabio José 2019-06-21 10:56:02 -03:00
parent a2ae5b9231
commit fb92f710ea
1 changed files with 4 additions and 11 deletions

View File

@ -1,9 +1,5 @@
var Spec02 = require("../../specs/spec_0_2.js");
function JSONParser() {
const spec02 = new Spec02();
function JSONParser(_spec) {
this.spec = (_spec) ? _spec : new Spec02();
}
/**
@ -45,13 +41,10 @@ function validate_spec(payload, spec) {
JSONParser.prototype.parse = function(payload) {
// Level 0 of validation: is that string? is that JSON?
var valid0 = validate_and_parse_as_json(payload);
//is that string? is that JSON?
var valid = validate_and_parse_as_json(payload);
// Level 1 of validation: is that follow a spec?
var valid1 = validate_spec(valid0, this.spec);
return valid1;
return valid;
}
module.exports = JSONParser;