njoguamos / laravel-kenya-mobile
A rule for validating Kenya mobile number in a Laravel application.
Installs: 1 554
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 1
Forks: 1
Open Issues: 1
Requires
- php: ^8.1
- illuminate/contracts: ^9.0 | ^10.0
- spatie/laravel-package-tools: ^1.14.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0 | ^8.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
README
Validate Kenyan Mobile Phone
A rule for validating Kenyan mobile number.
1. Why use this package
- 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.
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\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'], ]; } }
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.