From 8977f8cec4ca88f13528792a453eb27328e22845 Mon Sep 17 00:00:00 2001 From: "David T. Sadler" Date: Sun, 14 Nov 2021 08:49:37 +0000 Subject: Add description to todo --- src/DTS/Validator.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/DTS/Validator.php') 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); -- cgit v1.2.3-13-gbd6f