<?php

namespace App\Http\Requests\Api\V1\Cart;

use App\Rules\ProductStockIsAvailable;
use Illuminate\Foundation\Http\FormRequest;

class CartStoreRequest extends FormRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            'product_id' => ['required', 'integer', new ProductStockIsAvailable($this->product_quantity)],
            'product_quantity' => ['required', 'integer', 'min:1'],
        ];
    }
}
