<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'encrypted_nin' => [
                '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_nin.required' => 'Encrypted NIN is required.',
            'encrypted_nin.min'      => 'Invalid encrypted NIN format.',
            'encrypted_nin.max'      => 'Invalid encrypted NIN format.',
            'encrypted_nin.regex'    => 'Invalid encrypted NIN format.',
        ];
    }
}
