Laravel Validation for Mobile Number Example

Oct 02, 2019

.

Admin

Hello Guys,

Now, let's see an example of laravel validation for mobile number example. you will learn laravel 10 digit validation for mobile number. you will learn mobile and phone number validation. This tutorial will give you a simple example of how to add mobile number validation in laravel.

Example 1 :


/**

* Show the application dashboard.

*

* @return \Illuminate\Contracts\Support\Renderable

*/

public function index(Request $request)

{

$this->validate($request, [

'mobile' => 'required|digits:10'

]);

}

Example 2 :

/**

* Show the application dashboard.

*

* @return \Illuminate\Contracts\Support\Renderable

*/

public function index(Request $request)

{

$this->validate($request, [

'mobile' => 'required|numeric|between:9,11'

]);

}

Example 3 :

/**

* Show the application dashboard.

*

* @return \Illuminate\Contracts\Support\Renderable

*/

public function index(Request $request)

{

$this->validate($request, [

'mobile' => 'required|min:10|numeric'

]);

}

Example 4 :

/**

* Show the application dashboard.

*

* @return \Illuminate\Contracts\Support\Renderable

*/

public function index(Request $request)

{

$this->validate($request, [

'mobile' => 'required|regex:/(01)[0-9]{9}/'

]);

}

Example 5 :

/**

* Show the application dashboard.

*

* @return \Illuminate\Contracts\Support\Renderable

*/

public function index(Request $request)

{

$this->validate($request, [

'mobile' => 'required|regex:/^([0-9\s\-\+\(\)]*)$/|min:10'

]);

}

It will help you....

#Laravel

#Laravel 6