<?php

namespace Modules\HR\Http\Requests\LeavePolicy;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Modules\Core\Enums\StatusEnum;
use Modules\Core\Traits\FailedValidation;

class StoreLeavePolicyRequest extends FormRequest
{
    use FailedValidation;
    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'leave_type_id' => [
                'required',
                'integer',
            ],
            'annual_limit' => [
                'required',
                'integer',
                'min:0',
            ],
            'carry_forward' => [
                'required',
                'boolean',
            ],
            'encashable' => [
                'required',
                'boolean',
            ],
            'max_carry_forward_days' => [
                'required',
                'integer',
                'min:0',
            ],
            'status' => [
                'required',
                'string',
                Rule::in(StatusEnum::casesAsArray()),
            ],
        ];
    }

    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }
}
