<?php

namespace App\Http\Requests\Administrator;

use App\Http\Requests\ApiFormRequest;

class SubmitAdministratorAbsenceRequest extends ApiFormRequest
{
    public function authorize(): bool
    {
        return auth()->check();
    }

    public function rules(): array
    {
        return [
            'dates' => ['required', 'array', 'min:1'],
            'dates.*' => ['required', 'date_format:Y-m-d'],
            'reason_type' => ['nullable', 'string', 'max:100'],
            'reason' => ['required', 'string', 'max:2000'],
        ];
    }

    public function messages(): array
    {
        return [
            'dates.required' => 'At least one date is required.',
            'dates.array' => 'Dates must be submitted as an array.',
            'dates.min' => 'At least one date is required.',
            'dates.*.date_format' => 'Each date must be in Y-m-d format.',
            'reason.required' => 'Reason is required.',
        ];
    }
}