<?php

namespace App\Http\Requests\LeavePolicy;

use App\Models\Tenants\LeavePolicy;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

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

    public function rules(): array
    {
        return [
            'standard_type' => ['sometimes', Rule::in(LeavePolicy::STANDARD_TYPES)],
            'fiscal_start_month' => ['sometimes', 'integer', 'min:1', 'max:12'],
            'fiscal_start_day' => ['sometimes', 'integer', 'min:1', 'max:31'],
            'default_annual_leave' => ['sometimes', 'integer', 'min:0', 'max:100'],
            'additional_leave_per_year' => ['sometimes', 'integer', 'min:0', 'max:10'],
            'max_annual_leave' => ['sometimes', 'integer', 'min:0', 'max:100'],
            'carry_over_enabled' => ['sometimes', 'boolean'],
            'carry_over_max_days' => ['sometimes', 'integer', 'min:0', 'max:100'],
            'carry_over_expiry_months' => ['sometimes', 'integer', 'min:0', 'max:24'],
        ];
    }

    public function messages(): array
    {
        return [
            'standard_type.in' => __('validation.in', ['attribute' => '기준 유형']),
            'fiscal_start_month.min' => __('validation.min.numeric', ['attribute' => '기준월', 'min' => 1]),
            'fiscal_start_month.max' => __('validation.max.numeric', ['attribute' => '기준월', 'max' => 12]),
            'fiscal_start_day.min' => __('validation.min.numeric', ['attribute' => '기준일', 'min' => 1]),
            'fiscal_start_day.max' => __('validation.max.numeric', ['attribute' => '기준일', 'max' => 31]),
        ];
    }
}
