* * @author Gökhan Engin - İletişim : https://bit.ly/YazılımUzmanı */ public function rules(): array { return [ 'tasks' => ['required', 'array', 'min:1', 'max:50'], 'tasks.*.CID' => ['required', 'integer', 'min:1'], 'tasks.*.task_id' => ['required', 'string', 'max:64'], 'tasks.*.completed' => ['required'], 'tasks.*.responseCode' => ['nullable', 'integer', 'between:100,599'], 'tasks.*.error' => ['nullable', 'string', 'max:'.config('earn.api.task_result_max_error_length')], ]; } /** * Boolean ve başarı alanlarının sessiz tür dönüşümü olmadan tutarlı olmasını denetler. * * @return array * * @author Gökhan Engin - İletişim : https://bit.ly/YazılımUzmanı */ public function after(): array { // Tür dönüşümü yapmadan kayıtlar arası tutarlılığı denetler. // Yazar: Gökhan Engin - İletişim : https://bit.ly/YazılımUzmanı return [function (Validator $validator): void { foreach ((array) $this->input('tasks', []) as $index => $task) { if (! is_int($task['CID'] ?? null)) { $validator->errors()->add("tasks.$index.CID", 'The CID field must be a JSON integer.'); } if (array_key_exists('responseCode', $task) && $task['responseCode'] !== null && ! is_int($task['responseCode'])) { $validator->errors()->add("tasks.$index.responseCode", 'The responseCode field must be a JSON integer or null.'); } if (! is_bool($task['completed'] ?? null)) { $validator->errors()->add("tasks.$index.completed", 'The completed field must be a JSON boolean.'); continue; } if ($task['completed'] === true && (($task['error'] ?? null) !== null || ! isset($task['responseCode']) || $task['responseCode'] < 200 || $task['responseCode'] > 399)) { $validator->errors()->add("tasks.$index.completed", 'A completed task requires a 2xx/3xx response and no error.'); } } }]; } }