PHP Classes

Laravel Phone Number Validation: Validate phone numbers with country codes

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 63 All time: 10,430 This week: 78Up
Version License PHP version Categories
laravel-phone-valida 1.0The PHP License5PHP 5, Libraries, Validation
Description 

Author

This package can validate phone numbers with country codes.

It provides a Laravel service class that can validate phone numbers using regular expressions.

The package also provides classes that return regular expressions that can be used to validate numbers that include country codes of practically any country in the world.

Innovation Award
PHP Programming Innovation award nominee
January 2023
Number 9
Many applications need to take the phone numbers of users. Sometimes users enter the numbers with mistakes that make it impossible to reach them. Validation can help avoid users from entering invalid numbers.

There are many types of validation. The most robust validation methods require delivering SMS messages or making phone calls to the user's phone numbers. These methods are acceptable but may take a long time to conclude and often cost money.

More straightforward methods can be used in conjunction with these more robust methods, for instance, client-side or server-side validation of the numbers right after the users enter the numbers.

These more straightforward methods are not so robust but may avoid the most basic mistakes like entering phone numbers with wrong country codes or other errors that can be detected very quickly.

This package provides a service that uses complex regular expressions that can be used to detect simple mistakes.

Manuel Lemos
Picture of Roman Kozin
  Performance   Level  
Name: Roman Kozin is available for providing paid consulting. Contact Roman Kozin .
Classes: 8 packages by
Country: Ukraine Ukraine
Age: 29
All time rank: 270745 in Ukraine Ukraine
Week rank: 216 Up2 in Ukraine Ukraine Up
Innovation award
Innovation award
Nominee: 3x

Winner: 2x

Documentation

Laravel Phone Validation

Scrutinizer Code Quality Build Status Code Intelligence Status

Installation

composer require kield-01/laravel-phone-validation

Auto-Discovery

If You would like not to auto-discover this packages' ServiceProvider, You need to put this line into Your composer.json:

{
	"extra": {
		"laravel": {
			"dont-discover": [
				"kield-01/laravel-phone-validation"
			]
		}
	}
}

Provider registration (optional)

If You have this package to be non-discoverable, then You would need to register its ServiceProvider in the app.php:

<?php

return [
    'providers' => [
        KielD01\PhoneValidation\Providers\ValidationServiceProvider::class,    
    ]   
];

Available Validation rules


  Files folder image Files (6)  
File Role Description
Files folder imagesrc (2 directories)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file README.md Doc. Read me

  Files folder image Files (6)  /  src  
File Role Description
Files folder imageEnum (2 files)
Files folder imageProviders (1 file)

  Files folder image Files (6)  /  src  /  Enum  
File Role Description
  Plain text file PhoneRegex.php Class Class source
  Plain text file PhoneRules.php Class Class source

  Files folder image Files (6)  /  src  /  Providers  
File Role Description
  Plain text file ValidationServiceProvider.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:63
This week:0
All time:10,430
This week:78Up