<?php

namespace App\Http\Requests;

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

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

    public function rules(): array
    {
        return [
            'bank_id'             => ['sometimes', 'nullable', 'integer', Rule::exists('banks', 'id')->where('active', true)->whereNull('deleted_at')],
            'bank_code'           => ['sometimes', 'nullable', 'string', 'max:3'],
            'type'                => ['sometimes', Rule::in(['checking', 'savings'])],
            'branch_number'       => ['sometimes', 'string', 'max:4'],
            'branch_check_digit'  => ['sometimes', 'nullable', 'string', 'max:2'],
            'account_number'      => ['sometimes', 'string', 'max:13'],
            'account_check_digit' => ['sometimes', 'string', 'max:2'],
            'is_primary'          => ['sometimes', 'boolean'],
        ];
    }
}
