fix #22 tag & project validation

This commit is contained in:
DavidBadura
2015-06-28 13:34:51 +00:00
parent fb763a765e
commit 0a0a4f9788
2 changed files with 24 additions and 0 deletions

View File

@@ -21,6 +21,8 @@ use JMS\Serializer\SerializerBuilder;
*/
class TaskManager
{
const PATTERN = '/^[\wäüö]*$/i';
/**
* @var Taskwarrior
*/
@@ -216,6 +218,16 @@ class TaskManager
$errors[] = "A recurring task must also have a 'due' date.";
}
if (!preg_match(static::PATTERN, $task->getProject())) {
$errors[] = sprintf("Project with the name '%s' is not allowed", $task->getProject());
}
foreach ($task->getTags() as $tag) {
if (!preg_match(static::PATTERN, $tag)) {
$errors[] = sprintf("Tag with the name '%s' is not allowed", $tag);
}
}
return $errors;
}