<?php

namespace App\Http\Requests\Frontend\TopUp;

use Illuminate\Foundation\Http\FormRequest;

final class ValidatePromoRequest extends FormRequest
{
    public function authorize(): bool
    {
        return auth()->check();
    }

    /**
     * @return array<string, array<int, string>>
     */
    public function rules(): array
    {
        return [
            'code' => ['required', 'string'],
            'amount' => ['required', 'integer', 'min:0'],
        ];
    }

    public function getCode(): string
    {
        return strtoupper($this->validated('code'));
    }

    public function getAmount(): int
    {
        return (int) $this->validated('amount');
    }
}
