<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'name'          => 'required|string|max:150',
            'code'          => 'required|string|max:50|unique:yarns,code,' . ($this->yarn?->id ?? ''),
            'category'      => 'nullable|string|max:50',
            'count'         => 'nullable|string|max:20',
            'unit'          => 'nullable|string|max:10',
            'reorder_level' => 'nullable|numeric|min:0',
            'description'   => 'nullable|string|max:500',
            'is_active'     => 'nullable|boolean',
        ];
    }
}
