<?php

namespace App\Http\Requests\Auth;

use Illuminate\Foundation\Http\FormRequest;

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

    protected function prepareForValidation(): void
    {
        $this->merge([
            'userotp' => preg_replace('/\D+/', '', (string) $this->input('userotp')),
            'varifymobile' => preg_replace('/\D+/', '', (string) $this->input('varifymobile')),
        ]);
    }

    public function rules(): array
    {
        return [
            'userotp' => ['required', 'digits:6'],
            'varifymobile' => ['required', 'regex:/^[6-9][0-9]{9}$/'],
        ];
    }
}
