taobig/php-filter

A type validate & filter plugin for PHP projects

v0.3.0 2022-06-10 14:05 UTC

This package is auto-updated.

Last update: 2024-11-10 19:20:37 UTC


README

php-filter

A type validate & filter plugin for PHP projects

Latest Stable Version Latest Unstable Version Total Downloads License Build Status Coverage Status

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