<?php

namespace App\Http\Requests;

use App\Enums\OrganizerPrimaryEventType;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rules\Enum;
use Illuminate\Validation\Rules\Password;

class StoreManualOrganizerRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user() !== null && $this->user()->can('manage-organizer-requests');
    }

    /**
     * @return array<string, mixed>
     */
    public function rules(): array
    {
        return [
            'name' => ['required', 'string', 'max:255'],
            'email' => ['required', 'string', 'email', 'max:255', 'unique:users,email'],
            'password' => ['required', 'confirmed', Password::min(8)->mixedCase()->numbers()],
            'organization_name' => ['required', 'string', 'max:255'],
            'phone' => ['required', 'string', 'max:32'],
            'primary_event_type' => ['required', new Enum(OrganizerPrimaryEventType::class)],
        ];
    }
}
