taobig / php-filter
A type validate & filter plugin for PHP projects
v0.3.0
2022-06-10 14:05 UTC
Requires
- php: ^7.0 || ^8.0
Requires (Dev)
- php-coveralls/php-coveralls: ^2.4
- phpunit/phpunit: ~6.1 || ^9.0
README
php-filter
A type validate & filter plugin for PHP projects
INSTALLATION
Install via Composer
If you do not have Composer, you may install it refer to getcomposer.org.
You can then install this project template using the following command:
php composer.phar require taobig/php-filter
Usage
use taobig\filter\filters\TypeValidator;
TypeValidator::isString("hello world");//return true
TypeValidator::isString(1111.32333, false);//return true
TypeValidator::isInt(1111);//return true
TypeValidator::isInt("1111", false);//return true
TypeValidator::isIntList([1111]);//return true
TypeValidator::isIntList(["1111"], false);//return true
TypeValidator::isStringList(["1111"]);//return true
TypeValidator::isStringList([1111], false);//return true
$filter = new taobig\filter\filters\TypeFilter(['exceptionMessage'=>'parameters type error']);
$filter->stringVal("hello world");//return "hello world"
$filter->stringVal(1111.32333, false);//return "1111.32333"
$filter->intVal("1111", false);//return 1111
use taobig\filter\filters\MobileValidator;
TypeValidator::isChineseMobile("13800001111");//return true