/////////////////////////////////////////////////////////////////////////// Validate a task for addition, raising user-visible errors for inconsistent or incorrect inputs. This is called before `Task::validate`.
| 1420 | // Validate a task for addition, raising user-visible errors for inconsistent or |
| 1421 | // incorrect inputs. This is called before `Task::validate`. |
| 1422 | void 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: |