mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Hooks
- Reduced validation to simply checking that a description attribute is present. This is the bare minimum for the Task(const std::string&) contructor.
This commit is contained in:
parent
21bbedbfc5
commit
8d75d0c7f3
1 changed files with 4 additions and 12 deletions
|
@ -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")
|
||||
if (type == "string" && i->first == "description")
|
||||
foundDescription = true;
|
||||
|
||||
if (i->first == "status" && type == "string")
|
||||
foundStatus = 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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue