Task Validation

- Cleaned up the 'import' command due to the new validation code.
This commit is contained in:
Paul Beckingham 2011-08-31 02:14:05 -04:00
parent 12e1a30d2f
commit 641d4356c4

View file

@ -93,6 +93,9 @@ int CmdImport::execute (std::string& output)
trim (*line), ","),
"]"),
"[");
// Skip blanks. May be caused by the trim calls above.
if (! object.length ())
continue;
// Parse the whole thing.
json::value* root = json::parse (object);
@ -100,7 +103,6 @@ int CmdImport::execute (std::string& output)
{
json::object* root_obj = (json::object*)root;
Task task;
task.set ("uuid", uuid ());
// For each object element...
json_object_iter i;
@ -192,15 +194,13 @@ int CmdImport::execute (std::string& output)
}
}
task.validate ();
context.tdb2.add (task);
++count;
std::cout << " "
<< task.get ("uuid")
<< " "
<< task.get ("description")
<< "\n";
context.tdb2.add (task);
++count;
}
else
throw std::string ("Not a JSON object: ") + *line;