<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class AccessRequestsRequest extends FormRequest
{
    public function rules(): array
    {
        return [
            'game_username' => ['required', 'string', 'regex:/^[A-Za-z0-9_]{3,16}$/'],
            'message' => ['nullable', 'string', 'max:255'],
            'server_id' => ['nullable', 'required_without:server_slug', 'ulid', 'exists:game_servers,id'],
            'server_slug' => ['nullable', 'required_without:server_id', 'string', 'exists:game_servers,slug'],
        ];
    }

    public function authorize(): bool
    {
        return true;
    }
}
