<?php

namespace App\Http\Requests\V1\ProcessStep;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'step_name' => ['sometimes', 'required', 'string', 'max:100'],
            'is_required' => ['nullable', 'boolean'],
            'needs_approval' => ['nullable', 'boolean'],
            'needs_inspection' => ['nullable', 'boolean'],
            'is_active' => ['nullable', 'boolean'],
            'connection_type' => ['nullable', 'string', 'max:20'],
            'connection_target' => ['nullable', 'string', 'max:255'],
            'completion_type' => ['nullable', 'string', 'in:click_complete,selection_complete,inspection_complete'],
            'options' => ['nullable', 'array'],
            'options.inspection_setting' => ['nullable', 'array'],
            'options.inspection_scope' => ['nullable', 'array'],
            'options.inspection_scope.type' => ['nullable', 'string', 'in:all,sampling,group'],
            'options.inspection_scope.sample_size' => ['nullable', 'integer', 'min:1'],
            'options.inspection_scope.sample_base' => ['nullable', 'string', 'in:order,lot'],
        ];
    }

    public function attributes(): array
    {
        return [
            'step_name' => '단계명',
            'is_required' => '필수여부',
            'needs_approval' => '승인필요여부',
            'needs_inspection' => '검사필요여부',
            'is_active' => '사용여부',
            'connection_type' => '연결유형',
            'connection_target' => '연결대상',
            'completion_type' => '완료유형',
            'options' => '옵션',
            'options.inspection_setting' => '검사설정',
            'options.inspection_scope' => '검사범위',
            'options.inspection_scope.type' => '검사범위 유형',
            'options.inspection_scope.sample_size' => '샘플 크기',
            'options.inspection_scope.sample_base' => '샘플 기준',
        ];
    }
}
