<?php

namespace App\Http\Requests\Auth;

use Illuminate\Foundation\Http\FormRequest;

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

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

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