diff options
| author | David T. Sadler <davidtsadler@googlemail.com> | 2021-11-14 08:49:37 +0000 |
|---|---|---|
| committer | David T. Sadler <davidtsadler@googlemail.com> | 2021-11-14 08:49:37 +0000 |
| commit | 8977f8cec4ca88f13528792a453eb27328e22845 (patch) | |
| tree | 3479e7c7a3cec0a0ca923ea3c134d7243797b19d /src/DTS/Validator.php | |
| parent | 3226a642822a15e6cf937d3f0ec20fdf71651ea4 (diff) | |
Add description to todo
Diffstat (limited to 'src/DTS/Validator.php')
| -rw-r--r-- | src/DTS/Validator.php | 19 |
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); |
