定制 davidnsai/numlock 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

davidnsai/numlock

最新稳定版本:v1.0.0

Composer 安装命令:

composer require davidnsai/numlock

包简介

This a CodeIgniter Library for phone number validation.

README 文档

README

What is it?

Numlock is a CodeIgniter phone number validation library. This library is based on Google's # libphonenumber for PHP.

Installation

PHP versions 8.0 to PHP 8.2 are currently supported.

The PECL mbstring extension is required.

It is recommended to use composer to install the library.

$ composer require davidnsai/numlock

You can also use any other PSR-4 compliant autoloader.

Usage

For use in CodeIgniter projects, open the app/Config/Validation.php file and modify your code to look like the following code:

<?php
namespace  Config;
use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Validation\StrictRules\CreditCardRules;
use CodeIgniter\Validation\StrictRules\FileRules;
use CodeIgniter\Validation\StrictRules\FormatRules;
use CodeIgniter\Validation\StrictRules\Rules;
use Numlock\ValidatePhone;
 ...
class  Validation  extends  BaseConfig
{
	public  array  $ruleSets  =  [
		Rules::class,
		FormatRules::class,
		FileRules::class,
		CreditCardRules::class,
		ValidatePhone::class,
	];
 ...
 // More code here

The above code makes Numlock's phone number validation methods accessible for use in validation throughout the application. At present, Numlock has the following methods available for use:

	is_valid_phone(string  $phonenumber):  bool
	valid_phone_country(string  $phonenumber,  string  $iso_country_code):  bool

To validate your input, simply add these methods to your validation array. The valid_phone_country method. Takes the 2 letter iso country code as a parameter for validation.

Running tests

To run tests, use PHPUnit:

To run the tests locally, run the ./vendor/bin/phpunit script.

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-03-20