We can statically validate a phone or mobile number in Laravel using regex. But it will work for a specific country. So in this tutorial, we will validate the phone numbers in Laravel 10 for all countries using country code.

There is a beautiful package for validation phone numbers and the package name is "propaganistas/laravel-phone". Using this package we can easily validate phone number validation with country code in laravel 10. This laravel phone number validation package is good and it has two thousand plus git stars.

Let's see the error message of validation error if someone inputs an invalid phone number:


So now install this package:

composer require propaganistas/laravel-phone


Now update the validation.php file to show the exact error message:



return [
    'phone' => 'The :attribute field must be a valid number.',


Now to validate laravel 10 phone number validation, use this code like below:



namespace App\Http\Controllers;

use Illuminate\Http\Request;

class TutorialController extends Controller
    public function index()
        return view('welcome');

    public function store(Request $request)
            'phone' => 'phone:US,BD'

        return $request;


Now show the error message in your blade file like:



<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header" style="background: gray; color:#f1f7fa; font-weight:bold;">
                    Laravel 10 Phone Number Validation Example - Laravelia
                 <div class="card-body">                    
                        action="{{ route('user.store') }}" 
                        <div class="row mb-3">
                            <label class="col-sm-3 col-form-label">
                            <div class="col-sm-9">
                                <input type="text" class="form-control  @error('phone') is-invalid @enderror" name="phone">
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                        <div class="row mb-3">
                            <label class="col-sm-3 col-form-label"></label>
                            <div class="col-sm-9">
                                <button type="submit" class="btn btn-success btn-block text-white">Submit</button>


Read also: Laravel 10 Validate Any Type Of File Example



Now we know laravel phone number validation with country code. Hope this laravel phone number validation regex tutorial will help you. After completing laravel phone number validation package, your concept will be clear about laravel 10 phone number validation.