Validate that a phone number is in the correct format

1.1.0 2018-10-19 18:15 UTC

README

Validates phone number format.

68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6c61726176656c2d76616c69646174696f6e2d72756c65732f70686f6e652e7376673f7374796c653d666c61742d737175617265 68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6c61726176656c2d76616c69646174696f6e2d72756c65732f70686f6e652e7376673f7374796c653d666c61742d737175617265 68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6c61726176656c2d76616c69646174696f6e2d72756c65732f70686f6e652e7376673f7374796c653d666c61742d737175617265 68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6c61726176656c2d76616c69646174696f6e2d72756c65732f70686f6e652e7376673f7374796c653d666c61742d737175617265 687474703a2f2f696d672e736869656c64732e696f2f62616467652f617574686f722d4074796c657263643130302d626c75652e7376673f7374796c653d666c61742d737175617265

Installation

composer require laravel-validation-rules/phone

Usage

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!