<?php

namespace App\Http\Requests\Api;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class AiChatRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    /**
     * @return array<string, mixed>
     */
    public function rules(): array
    {
        return [
            'prompt' => ['required', 'string', 'max:20000'],
            'conversation_id' => [
                'nullable',
                'integer',
                Rule::exists('conversations', 'id')->where(
                    fn ($q) => $q->where('user_id', $this->user()->id)
                ),
            ],
        ];
    }
}
