<?php

namespace App\Http\Requests\V1\AccountSubject;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'name' => ['sometimes', 'string', 'max:100'],
            'category' => ['nullable', 'string', 'in:asset,liability,capital,revenue,expense'],
            'sub_category' => ['nullable', 'string', 'max:50'],
            'parent_code' => ['nullable', 'string', 'max:10'],
            'depth' => ['nullable', 'integer', 'in:1,2,3'],
            'department_type' => ['nullable', 'string', 'in:common,manufacturing,admin'],
            'description' => ['nullable', 'string', 'max:500'],
            'sort_order' => ['nullable', 'integer'],
        ];
    }

    public function messages(): array
    {
        return [
            'category.in' => '유효한 분류를 선택하세요.',
            'depth.in' => '계층은 1(대), 2(중), 3(소) 중 하나여야 합니다.',
            'department_type.in' => '부문은 common, manufacturing, admin 중 하나여야 합니다.',
        ];
    }
}
