<?php

namespace Modules\Inventory\Http\Requests\Product;

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

class PreviewProductAccountsRequest extends FormRequest
{
    use FailedValidation;

    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'name' => ['required','string','max:255'],
            'sku' => ['nullable','string','max:100'],
            'category_id' => ['required','integer','exists:categories,id'],
            'product_type' => [
                'required',
                Rule::in(ProductTypeEnum::casesAsArray())
            ],
        ];
    }

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