<?php

namespace App\Http\Requests\Material;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'category_id' => 'nullable|integer',
            'name' => 'sometimes|string|max:100',
            'unit' => 'sometimes|string|max:20',
            'is_inspection' => 'nullable|in:Y,N',
            'search_tag' => 'nullable|string|max:255',
            'remarks' => 'nullable|string|max:500',
            'attributes' => 'nullable|array',
            'attributes.*.label' => 'required|string|max:50',
            'attributes.*.value' => 'required|string|max:100',
            'attributes.*.unit' => 'nullable|string|max:20',
            'options' => 'nullable|array',
            'material_code' => 'nullable|string|max:30',
            'specification' => 'nullable|string|max:255',
        ];
    }
}
