<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'encrypted_bvn' => [
                'required',
                'string',
                // RSA-2048 + OAEP ciphertext is 256 bytes → ~344 base64 chars.
                // Allow a reasonable window around that; reject anything wildly outside range.
                'min:300',
                'max:400',
                'regex:/^[A-Za-z0-9+\/]*={0,2}$/',
            ],
        ];
    }

    public function messages(): array
    {
        return [
            'encrypted_bvn.required' => 'Encrypted BVN is required.',
            'encrypted_bvn.min'      => 'Invalid encrypted BVN format.',
            'encrypted_bvn.max'      => 'Invalid encrypted BVN format.',
            'encrypted_bvn.regex'    => 'Invalid encrypted BVN format.',
        ];
    }
}
