From df1562adc983c0e590ce7405443b94c1c656065c Mon Sep 17 00:00:00 2001 From: konard Date: Fri, 14 Nov 2025 23:48:11 +0000 Subject: [PATCH] fix(tasks): accept 'none' as valid recurrence value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: When creating a non-recurring task (recurrence: "none") from the frontend, the API returned validation errors: - "The selected recurrence is invalid." - "The recurrence time field must match the format H:i:s." This happened because the validation only accepted 'daily', 'weekly', and 'monthly' values, but the frontend sends 'none' for non-recurring tasks. Solution: 1. Updated TaskController validation to accept 'none' in recurrence enum 2. Modified custom validation logic to skip checks when recurrence is 'none' 3. Updated swagger.yaml to document 'none' as a valid recurrence option Changes: - TaskController.php:211,299 - Added 'none' to recurrence validation enum - TaskController.php:223,313 - Skip validation when recurrence is 'none' - swagger.yaml:248,2389,2540 - Added 'none' to recurrence enum in all schemas Related to: xierongchuan/TaskMateFrontend#54 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- app/Http/Controllers/Api/V1/TaskController.php | 8 ++++---- swagger.yaml | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/Api/V1/TaskController.php b/app/Http/Controllers/Api/V1/TaskController.php index ca9fe97..9785dbb 100644 --- a/app/Http/Controllers/Api/V1/TaskController.php +++ b/app/Http/Controllers/Api/V1/TaskController.php @@ -208,7 +208,7 @@ public function store(Request $request) 'dealership_id' => 'nullable|exists:auto_dealerships,id', 'appear_date' => 'nullable|string|after_or_equal:now', // Bug #4: не раньше текущего времени 'deadline' => 'nullable|string', - 'recurrence' => 'nullable|string|in:daily,weekly,monthly', + 'recurrence' => 'nullable|string|in:none,daily,weekly,monthly', 'recurrence_time' => 'nullable|date_format:H:i', // Время для повторяющихся задач 'recurrence_day_of_week' => 'nullable|integer|min:1|max:7', // 1=Пн, 7=Вс 'recurrence_day_of_month' => 'nullable|integer|min:-2|max:31', // -1=первое, -2=последнее, 1-31=число @@ -220,7 +220,7 @@ public function store(Request $request) ]); // Custom validation for recurring tasks - if (!empty($validated['recurrence'])) { + if (!empty($validated['recurrence']) && $validated['recurrence'] !== 'none') { switch ($validated['recurrence']) { case 'daily': // Daily tasks require recurrence_time @@ -296,7 +296,7 @@ public function update(Request $request, $id) 'dealership_id' => 'nullable|exists:auto_dealerships,id', 'appear_date' => 'nullable|string', 'deadline' => 'nullable|string', - 'recurrence' => 'nullable|string|in:daily,weekly,monthly', + 'recurrence' => 'nullable|string|in:none,daily,weekly,monthly', 'recurrence_time' => 'nullable|date_format:H:i', 'recurrence_day_of_week' => 'nullable|integer|min:1|max:7', 'recurrence_day_of_month' => 'nullable|integer|min:-2|max:31', @@ -310,7 +310,7 @@ public function update(Request $request, $id) // Custom validation for recurring tasks $recurrence = $validated['recurrence'] ?? $task->recurrence; - if (!empty($recurrence)) { + if (!empty($recurrence) && $recurrence !== 'none') { $recurrenceTime = $validated['recurrence_time'] ?? $task->recurrence_time; $recurrenceDayOfWeek = $validated['recurrence_day_of_week'] ?? $task->recurrence_day_of_week; $recurrenceDayOfMonth = $validated['recurrence_day_of_month'] ?? $task->recurrence_day_of_month; diff --git a/swagger.yaml b/swagger.yaml index 748ccff..7988955 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -245,7 +245,7 @@ components: example: 2025-10-15T18:00:00Z recurrence: type: string - enum: [daily, weekly, monthly] + enum: [none, daily, weekly, monthly] nullable: true example: weekly recurrence_time: @@ -2386,7 +2386,7 @@ paths: example: "2025-10-15T18:00:00Z" recurrence: type: string - enum: [daily, weekly, monthly] + enum: [none, daily, weekly, monthly] nullable: true example: weekly recurrence_time: @@ -2537,7 +2537,7 @@ paths: example: "2025-10-16T18:00:00Z" recurrence: type: string - enum: [daily, weekly, monthly] + enum: [none, daily, weekly, monthly] nullable: true example: daily recurrence_time: