summaryrefslogtreecommitdiff
path: root/src/DTS/Validator.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/DTS/Validator.php')
-rw-r--r--src/DTS/Validator.php19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/DTS/Validator.php b/src/DTS/Validator.php
index 2f9c255..a2ab48f 100644
--- a/src/DTS/Validator.php
+++ b/src/DTS/Validator.php
@@ -21,6 +21,8 @@ class Validator
$this->validateTask($request['task'], 2, 256);
+ $this->validateDescription($request['description'], 8, 512);
+
$this->validateTag($request['tag'], 2, 16);
}
@@ -37,6 +39,23 @@ class Validator
}
}
+ private function validateDescription(string $description, int $minLength, int $maxLength): void
+ {
+ $description = trim($description);
+
+ if ($description === '') {
+ return;
+ }
+
+ if (strlen($description) < $minLength || strlen($description) > $maxLength) {
+ $this->errors->add('description', "Must be between $minLength and $maxLength in characters in length");
+ }
+
+ if (!$this->errors->has('tite')) {
+ $this->validated->description = $description;
+ }
+ }
+
private function validateTag(string $tag, int $minLength, int $maxLength): void
{
$tag = trim($tag);