mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-21 07:43:08 +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:
|
// The absolute minimum a task needs is:
|
||||||
bool foundDescription = false;
|
bool foundDescription = false;
|
||||||
bool foundStatus = false;
|
|
||||||
|
|
||||||
// Parse the whole thing.
|
// Parse the whole thing.
|
||||||
json::value* root = json::parse (input);
|
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.
|
// If the attribute is a recognized column.
|
||||||
std::string type = Task::attributes[i->first];
|
std::string type = Task::attributes[i->first];
|
||||||
if (type != "")
|
if (type == "string" && i->first == "description")
|
||||||
{
|
|
||||||
if (i->first == "description" && type == "string")
|
|
||||||
foundDescription = true;
|
foundDescription = true;
|
||||||
|
|
||||||
if (i->first == "status" && type == "string")
|
|
||||||
foundStatus = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
throw std::string ("Object expected.");
|
||||||
|
|
||||||
// It's JSON, but is it a task?
|
// It's JSON, but is it a task?
|
||||||
if (! foundDescription)
|
if (! foundDescription)
|
||||||
throw std::string ("Missing 'description' attribute, of type 'string'.");
|
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.
|
// Yep, looks like a JSON task.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue