A rule for validating Kenyan mobile number.
- Save time from implementing your own validation rule.
- Tested with phone number approved by Communications Authority of Kenya supported.
Info This package assumed that the phone number is either a 9 digit e.g
700325008
or 10 digit0700325008
. Number with leadingzero (0)
should be casted into an(int)
before storing in a database. It also assumed that you will store the prefix+254
in different column or table.
You can install the package via composer:
composer require njoguamos/laravel-kenya-mobile
<?php
namespace App\Http\Requests;
use NjoguAmos\KeMobile\KenyaMobileRule;
use Illuminate\Foundation\Http\FormRequest;
class RegisterUserRequest extends FormRequest
{
/** @return array<string, mixed> */
public function rules(): array
{
return [
// ... other rules
'phone' => ['nullable', new KenyaMobileRule(),'unique:users,phone'],
];
}
}
Carrier | Prefix |
---|---|
Airtel Networks Kenya Ltd | 100, 101, 102, 103, 104, 105, 106 |
Safaricom PLC | 110, 111, 112, 113, 114, 115 |
Jambo Telcoms Ltd | 120 |
Infura Ltd | 124 |
Hidiga Investments Ltd | 126 |
Webtribe Ltd | 128 |
NRG Media Ltd | 130 |
Safaricom PLC | 700, 701, 702, 703, 704, 705, 706, 707, 708, 709 |
Safaricom PLC | 710, 711, 712, 713, 714, 715, 716, 717, 718, 719 |
Safaricom PLC | 720, 721, 722, 723, 724, 725, 726, 727, 728, 729 |
Airtel Networks Kenya Ltd | 730, 731, 732, 733, 734, 735, 736, 737, 738, 739 |
Safaricom PLC | 740, 741, 742, 743 |
Homelands Media Ltd | 744 |
Safaricom PLC | 745, 746 |
Jamii Telecoms Ltd | 747 |
Safaricom Ltd | 748 |
IEBC in KIEMS Kits | 749 |
Airtel Networks Kenya Ltd | 750, 751, 752, 753, 754, 755, 756 |
Safaricom Ltd | 757, 758, 759 |
Mobile Pay Ltd | 760 |
Eferio Kenya Ltd | 761 |
Airtel Networks Kenya Ltd | 762 |
Finserve Africa Ltd | 763, 764, 765, 766 |
Airtel Networks Kenya Ltd | 767 |
Safaricom PLC | 768, 769 |
Telkom Kenya Ltd | 770, 771, 772, 773, 774, 775, 776, 777, 778, 779 |
Airtel Networks Kenya Ltd | 780, 781, 782, 783, 784, 785, 786, 787, 788, 789 |
Safaricom PLC | 790, 791, 792, 793, 794, 795, 796, 797, 798, 799 |
composer test
Please see RELEASES for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email njoguamos@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.