Laravel Validation for Mobile Number Example
Oct 02, 2019
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....
- How to Notifications With database Driver in Laravel 11?
- How to Send Email Via Notification in Laravel 11?
- How to Install and Configure Laravel 11 Debugbar?
- How to Like Dislike System in Laravel 11?
- How to Paginate a Model with Relationship in Laravel 11?
- Laravel 11 Upload Files to Amazon S3 Example
- Laravel 11 Send WhatsApp Messages Example
- Laravel 11 Rest API Authentication Using JWT Tutorial