From fb92f710ead91a13d0bfa466b195e4e8ea975679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabio=20Jos=C3=A9?= Date: Fri, 21 Jun 2019 10:56:02 -0300 Subject: [PATCH] Remove the responsability of spec checking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabio José --- lib/formats/json/parser.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/lib/formats/json/parser.js b/lib/formats/json/parser.js index 115b6ae..66e5419 100644 --- a/lib/formats/json/parser.js +++ b/lib/formats/json/parser.js @@ -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;