MCPcopy Create free account
hub / github.com/GothenburgBitFactory/taskwarrior / validate_add

Method validate_add

src/Task.cpp:1422–1432  ·  view source on GitHub ↗

/////////////////////////////////////////////////////////////////////////// Validate a task for addition, raising user-visible errors for inconsistent or incorrect inputs. This is called before `Task::validate`.

Source from the content-addressed store, hash-verified

1420// Validate a task for addition, raising user-visible errors for inconsistent or
1421// incorrect inputs. This is called before `Task::validate`.
1422void Task::validate_add() {
1423 // There is no fixing a missing description.
1424 if (!has("description"))
1425 throw std::string("A task must have a description.");
1426 else if (get("description") == "")
1427 throw std::string("Cannot add a task that is blank.");
1428
1429 // Cannot have an old-style recur frequency with no due date - when would it recur?
1430 if (has("recur") && (!has("due") || get("due") == ""))
1431 throw std::string("A recurring task must also have a 'due' date.");
1432}
1433
1434////////////////////////////////////////////////////////////////////////////////
1435// The purpose of Task::validate is three-fold:

Callers 1

executeMethod · 0.80

Calls 1

getFunction · 0.70

Tested by

no test coverage detected