Laravel 6 validation for mobile number

Nicesnippets

83

02-10-2019


hi guys,

In this example,I will learn you mobile number validation. you can only 10 digit mobile number then validation digit:10.you can simply apply to validation to mobile number in laravel 6.

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....