<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class UpdateRecurringTransactionRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        // Authorization handled by route model binding in AppServiceProvider
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'name' => 'required|string|max:100',
            'type' => 'required|in:income,expense',
            'account_id' => 'required|exists:accounts,id',
            'category_id' => 'nullable|exists:categories,id',
            'amount' => 'required|numeric|min:0.01',
            'frequency' => 'required|in:daily,weekly,biweekly,monthly,quarterly,yearly',
            'interval' => 'nullable|integer|min:1|max:365',
            'start_date' => 'required|date',
            'end_date' => 'nullable|date|after:start_date',
            'next_due_date' => 'nullable|date',
            'description' => 'nullable|string|max:500',
            'payee' => 'nullable|string|max:200',
            'auto_create' => 'boolean',
            'reminder_days' => 'nullable|integer|min:0|max:30',
            'is_active' => 'boolean',
        ];
    }
}
