<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class CreatePixRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user() !== null;
    }

    public function rules(): array
    {
        return [
            'amount'             => ['required', 'numeric', 'min:1', 'max:5000'],
            'payer.email'        => ['required', 'email'],
            'payer.first_name'   => ['nullable', 'string', 'max:50'],
            'payer.last_name'    => ['nullable', 'string', 'max:50'],
            'payer.document.type'   => ['required', 'in:CPF,CNPJ'],
            'payer.document.number' => ['required', 'string', 'min:11', 'max:18'],
        ];
    }
}