<?php

namespace App\Http\Requests\Event;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'special_requests'            => ['nullable', 'array'],
            'co_travelers'                => ['nullable', 'array', 'max:10'],
            'co_travelers.*.name'         => ['required_with:co_travelers', 'string', 'max:255'],
            'co_travelers.*.its_number'   => ['nullable', 'string', 'max:20'],
            'co_travelers.*.relationship' => ['nullable', 'string', 'max:50'],
        ];
    }

    public function messages(): array
    {
        return [
            'co_travelers.*.name.required_with' => 'Each co-traveler must have a name.',
        ];
    }
}
