tylercd100/laravel-validator-phone

验证电话号码格式是否正确

1.3.0 2017-02-23 21:29 UTC

This package is auto-updated.

Last update: 2024-09-12 09:28:59 UTC


README

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

此包已迁移至此处以供laravel 5.5+使用。请使用该版本。还可以查看这些其他社区验证规则

此包仅检查电话号码格式,而不检查实际号码的有效性。

安装

通过 composer 安装 - 在终端中

composer require tylercd100/laravel-validator-phone

现在,将以下内容添加到您的 config/app.php 文件中的 providers 数组中

Tylercd100\Validator\Phone\ServiceProvider::class

用法

// 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