<?php

namespace Modules\HR\Http\Requests\LeaveType;

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

class StoreLeaveTypeRequest extends FormRequest
{
    use FailedValidation;
    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'name' => [
                'required',
                'string',
                'max:255',
                'unique:leave_types,name',
            ],
            'days_per_year' => [
                'required',
                'integer',
                'min:0',
            ],
            'is_paid' => [
                'nullable',
                'boolean',
            ],
            'is_encashable' => [
                'nullable',
                'boolean',
            ],
            'status' => [
                'required',
                'string',
                Rule::in(StatusEnum::casesAsArray()),
            ],
        ];
    }

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