Laravel Kenya Mobile is a Laravel package that provides a validation rule for Kenyan mobile phone numbers. The package validates phone numbers in both 9-digit (e.g., 700325008) and 10-digit (e.g., 0700325008) formats.
# Validate Kenyan Mobile Phone
A rule for validating Kenyan mobile number. You can either validate phone number with 9 or 10 digits such as `700325008` or `0700325008` or validate full phone number such as `254700325008`.
## 1. Why use this package
1. Save time from implementing your own validation rule.
2. Tested with phone number approved by Communications Authority of Kenya supported.
## 2. Installation
| Version | Supported Laravel |
|---------|-------------------|
| 1.x | 9.x, 10.x |
| 2.x | 11.x, 12.x |
| 3.x | 12.x, 13.x |
You can install the package via composer:
```bash
composer require njoguamos/laravel-kenya-mobile
```
## 3. Usage
### 3.1 Inside a form request
```php
*/
public function rules(): array
{
return [
// ... other rules
// Validate phone number with 9 or 10 digits
'phone' => ['nullable', new KenyaMobileRule(),'unique:users,phone'],
// Or validate full phone number
'full_phone' => ['nullable', new KenyaMobileFullRule(),'unique:users,full_phone'],
];
}
}
```
### 3.2 Supported mobile numbers
| 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 | …