tylercd100 / laravel-validator-phone by tylercd100

Validate that a phone number is in the correct format
4,368
3
2
Package Data
Maintainer Username: tylercd100
Maintainer Contact: tylercd100@gmail.com (Tyler Arbon)
Package Create Date: 2017-02-14
Package Last Update: 2017-10-18
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-11-22 03:10:29
Package Statistics
Total Downloads: 4,368
Monthly Downloads: 1
Daily Downloads: 0
Total Stars: 3
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

Validate phone numbers with Laravel 5

Latest Version Software License Build Status Scrutinizer Code Quality Code Coverage Total Downloads

This Package has moved to here for laravel 5.5+. Please use that instead. Also check out these other community validation rules

This package only checks phone number formatting and not actual number validity.

Installation

Install via composer - In the terminal:

composer require tylercd100/laravel-validator-phone

Now add the following to the providers array in your config/app.php

Tylercd100\Validator\Phone\ServiceProvider::class

Usage

// Test any phone number
Validator::make(['test' => '15556667777'], ['test' => 'phone']); //true
Validator::make(['test' => '+15556667777'], ['test' => 'phone']); //true
Validator::make(['test' => '+1 (555) 666-7777'], ['test' => 'phone']); //true

// Test for E164
Validator::make(['test' => '+15556667777'], ['test' => 'phone:E164']); //true

// Test for NANP (North American Numbering Plan)
Validator::make(['test' => '+1 (555) 666-7777'], ['test' => 'phone:NANP']); //true

// Test for digits only
Validator::make(['test' => '15556667777'], ['test' => 'phone:digits']); //true