<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

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

    public function rules(): array
    {
        return [
            'recipient_default_bank_account'                     => ['required', 'array'],
            'recipient_default_bank_account.holder_name'         => ['sometimes', 'nullable', 'string', 'max:255'],
            'recipient_default_bank_account.holder_type'         => ['sometimes', 'nullable', Rule::in(['individual', 'company'])],
            'recipient_default_bank_account.holder_document'     => ['sometimes', 'nullable', 'string', 'max:20'],
            'recipient_default_bank_account.bank'                => ['required', 'string', 'max:20'],
            'recipient_default_bank_account.branch_number'       => ['required', 'string', 'max:20'],
            'recipient_default_bank_account.branch_check_digit'  => ['sometimes', 'nullable', 'string', 'max:10'],
            'recipient_default_bank_account.account_number'      => ['required', 'string', 'max:13'],
            'recipient_default_bank_account.account_check_digit' => ['required', 'string', 'max:10'],
            'recipient_default_bank_account.type'                => ['required', Rule::in(['checking', 'savings'])],
            'recipient_default_bank_account.metadata'            => ['sometimes', 'array'],
        ];
    }
}
