njoguamos / laravel-kenya-mobile
A rule for validating Kenya mobile number in a Laravel 11+ application.
Installs: 1 698
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- php: ^8.2
- illuminate/contracts: ^11.0
- spatie/laravel-package-tools: ^1.16.0
Requires (Dev)
- laravel/pint: ^1
- nunomaduro/collision: ^8.5.0
- nunomaduro/larastan: ^3.0.0
- orchestra/testbench: ^9.0
- pestphp/pest: ^v3.5.1
- pestphp/pest-plugin-laravel: ^3.0.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
README
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
- Save time from implementing your own validation rule.
- Tested with phone number approved by Communications Authority of Kenya supported.
2. Installation
You can install the package via composer:
composer require njoguamos/laravel-kenya-mobile
3. Usage
3.1 Inside a form request
<?php namespace App\Http\Requests; use NjoguAmos\KeMobile\KenyaMobileFullRule; use NjoguAmos\KeMobile\KenyaMobileRule; use Illuminate\Foundation\Http\FormRequest; class RegisterUserRequest extends FormRequest { /** @return array<string, mixed> */ 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
4. Testing
composer test
5. Changelog
Please see RELEASES for more information what has changed recently.
6. Contributing
Please see CONTRIBUTING for details.
7. Security Vulnerabilities
If you discover any security related issues, please email njoguamos@gmail.com instead of using the issue tracker.
8. Credits
9. License
The MIT License (MIT). Please see License File for more information.