Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/laravel-validation-rules/phone
Validate phone number format
https://github.com/laravel-validation-rules/phone
laravel phone php rules validation
Last synced: 3 months ago
JSON representation
Validate phone number format
- Host: GitHub
- URL: https://github.com/laravel-validation-rules/phone
- Owner: laravel-validation-rules
- License: apache-2.0
- Created: 2017-09-10T06:46:25.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-04-16T12:31:28.000Z (7 months ago)
- Last Synced: 2024-07-21T02:04:35.516Z (4 months ago)
- Topics: laravel, phone, php, rules, validation
- Language: PHP
- Homepage: https://laravel-validation-rules.github.io/
- Size: 28.3 KB
- Stars: 68
- Watchers: 6
- Forks: 12
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Phone
Validates phone number format.
## Installation
```bash
composer require laravel-validation-rules/phone
```## Usage
```php
use LVR\Phone\Phone;
use LVR\Phone\E123;
use LVR\Phone\E164;
use LVR\Phone\NANP;
use LVR\Phone\Digits;// Test any phone number
$request->validate(['test' => '15556667777'], ['test' => new Phone]); // Pass!
$request->validate(['test' => '+15556667777'], ['test' => new Phone]); // Pass!
$request->validate(['test' => '+1 (555) 666-7777'], ['test' => new Phone]); // Pass!// Test for E123
$request->validate(['test' => '+22 555 666 7777'], ['test' => new E123]); // Pass!// Test for E164
$request->validate(['test' => '+15556667777'], ['test' => new E164]); // Pass!// Test for NANP (North American Numbering Plan)
$request->validate(['test' => '+1 (555) 666-7777'], ['test' => new NANP); // Pass!// Test for digits only
$request->validate(['test' => '15556667777'], ['test' => new Digits]); // Pass!
```