<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'phone_number' => [
                'required',
                'string',
                // Accept local (08012345678), international without plus (2348012345678),
                // or with plus (+2348012345678). Between 10 and 14 digits.
                'regex:/^\+?[0-9]{10,14}$/',
            ],
        ];
    }

    public function messages(): array
    {
        return [
            'phone_number.required' => 'Phone number is required.',
            'phone_number.regex'    => 'Invalid phone number format.',
        ];
    }
}
