diff --git a/lib/Service/CardService.php b/lib/Service/CardService.php index f5995874f..b9ebe8e75 100644 --- a/lib/Service/CardService.php +++ b/lib/Service/CardService.php @@ -234,7 +234,7 @@ public function delete(int $id): Card { * @throws BadRequestException */ public function update(int $id, string $title, int $stackId, string $type, string $owner, string $description = '', int $order = 0, ?string $duedate = null, ?int $deletedAt = null, ?bool $archived = null, ?OptionalNullableValue $done = null): Card { - $this->cardServiceValidator->check(compact('id', 'title', 'stackId', 'type', 'owner', 'order')); + $this->cardServiceValidator->check(compact('id', 'title', 'stackId', 'type', 'owner', 'order', 'duedate')); $this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT, allowDeletedCard: true); $this->permissionService->checkPermission($this->stackMapper, $stackId, Acl::PERMISSION_EDIT); diff --git a/lib/Validators/BaseValidator.php b/lib/Validators/BaseValidator.php index 6ae05d4a9..2e358768b 100644 --- a/lib/Validators/BaseValidator.php +++ b/lib/Validators/BaseValidator.php @@ -112,6 +112,16 @@ private function not_empty($value): bool { return !empty($value); } + /** + * @param $value + * @return bool + */ + private function date(string $value): bool { + $date = \DateTime::createFromFormat('Y-m-d\TH:i:s.v\Z', $value) + ?: \DateTime::createFromFormat(\DateTime::ATOM, $value); + return $date !== false; + } + /** * @throws Exception */ diff --git a/lib/Validators/CardServiceValidator.php b/lib/Validators/CardServiceValidator.php index ddbcf8738..bc392c76e 100644 --- a/lib/Validators/CardServiceValidator.php +++ b/lib/Validators/CardServiceValidator.php @@ -21,6 +21,7 @@ public function rules() { 'type' => ['not_empty', 'not_null', 'not_false', 'max:64'], 'order' => ['numeric'], 'owner' => ['not_empty', 'not_null', 'not_false', 'max:64'], + 'duedate' => ['date'], ]; } } diff --git a/src/components/card/DueDateSelector.vue b/src/components/card/DueDateSelector.vue index b9f2669d7..3d2b493e9 100644 --- a/src/components/card/DueDateSelector.vue +++ b/src/components/card/DueDateSelector.vue @@ -12,7 +12,8 @@ v-model="duedate" :placeholder="t('deck', 'Set a due date')" :hide-label="true" - type="datetime-local" /> + type="datetime-local" + :max="new Date('9999-12-31T23:59:59')"/>