From 8d75d0c7f3919837805c7449485339acc37368a6 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 18 Oct 2014 17:23:39 -0400 Subject: [PATCH] Hooks - Reduced validation to simply checking that a description attribute is present. This is the bare minimum for the Task(const std::string&) contructor. --- src/Hooks.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/Hooks.cpp b/src/Hooks.cpp index d2b31f1c5..e2ffcf6ba 100644 --- a/src/Hooks.cpp +++ b/src/Hooks.cpp @@ -415,7 +415,6 @@ bool Hooks::isJSON (const std::string& input) const { // The absolute minimum a task needs is: bool foundDescription = false; - bool foundStatus = false; // Parse the whole thing. json::value* root = json::parse (input); @@ -431,24 +430,17 @@ bool Hooks::isJSON (const std::string& input) const { // If the attribute is a recognized column. std::string type = Task::attributes[i->first]; - if (type != "") - { - if (i->first == "description" && type == "string") - foundDescription = true; - - if (i->first == "status" && type == "string") - foundStatus = true; - } + if (type == "string" && i->first == "description") + foundDescription = true; } } + else + throw std::string ("Object expected."); // It's JSON, but is it a task? if (! foundDescription) throw std::string ("Missing 'description' attribute, of type 'string'."); - if (! foundStatus) - throw std::string ("Missing 'status' attribute, of type 'string'."); - // Yep, looks like a JSON task. return true; }