<?php

namespace App\Domains\FiestaFutbolInfantil\Requests;

use Illuminate\Foundation\Http\FormRequest;

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

    /** @return array<string, mixed> */
    public function rules(): array
    {
        return [
            'variants' => ['required', 'array', 'min:1', 'max:500'],
            'variants.*' => ['required', 'array:id,title,description,stock,price'],
            'variants.*.id' => ['sometimes', 'nullable', 'integer', 'distinct'],
            'variants.*.title' => ['required', 'string', 'max:255'],
            'variants.*.description' => ['sometimes', 'nullable', 'string'],
            'variants.*.stock' => ['required', 'integer', 'min:0'],
            'variants.*.price' => ['required', 'numeric', 'min:0', 'max:99999999.99'],
        ];
    }
}
