Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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!
```