\Imi\ValidateValidatorHelper

验证器工具类

Summary

Methods
Properties
Constants
regex()
decimal()
int()
number()
length()
lengthChar()
emptyStr()
notEmptyStr()
email()
cnMobile()
tel()
mobile()
phone()
postcode()
url()
qq()
ip()
ipv4()
ipv6()
between()
betweenEqual()
lt()
ltEqual()
gt()
gtEqual()
equal()
unequal()
compare()
in()
notIn()
inEnum()
notInEnum()
cnIdcard()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

regex()

regex(mixed  $value, string  $rule) : boolean

正则验证

Parameters

mixed $value
string $rule

Returns

boolean

decimal()

decimal(float  $value, float|null  $min = null, float|null  $max = null, integer  $accuracy = null) : boolean

小数验证

Parameters

float $value
float|null $min
float|null $max
integer $accuracy

Returns

boolean

int()

int(integer  $value, integer|null  $min = null, integer|null  $max = null) : boolean

整数验证

Parameters

integer $value
integer|null $min
integer|null $max

Returns

boolean

number()

number(float  $value, float|null  $min = null, float|null  $max = null, integer|null  $accuracy = null) : boolean

数值验证,允许整数和小数

Parameters

float $value
float|null $min
float|null $max
integer|null $accuracy

Returns

boolean

length()

length(string  $val, integer  $min, integer  $max = null) : boolean

判断文本长度,以字节为单位

Parameters

string $val
integer $min
integer $max

Returns

boolean

lengthChar()

lengthChar(string  $val, integer  $min, integer  $max = null) : boolean

判断文本长度,以字符为单位

Parameters

string $val
integer $min
integer $max

Returns

boolean

emptyStr()

emptyStr(string  $str) : boolean

判断空文本

Parameters

string $str

Returns

boolean

notEmptyStr()

notEmptyStr(string  $str) : boolean

判断不为空文本

Parameters

string $str

Returns

boolean

email()

email(string  $email) : boolean

检测邮箱格式

Parameters

string $email

Returns

boolean

cnMobile()

cnMobile(string  $str) : boolean

检测中国手机号码格式

Parameters

string $str

Returns

boolean

tel()

tel(string  $str) : boolean

检测中国电话号码格式,支持400、800等

Parameters

string $str

Returns

boolean

mobile()

mobile(string  $str) : boolean

检测中国手机电话号码格式

Parameters

string $str

Returns

boolean

phone()

phone(string  $str) : string

检测是否符合中国固话或手机格式,支持400、800等

Parameters

string $str

Returns

string

postcode()

postcode(string  $str) : boolean

检测中国邮政编码

Parameters

string $str

Returns

boolean

url()

url(string  $str) : boolean

检测URL地址

Parameters

string $str

Returns

boolean

qq()

qq(string  $str) : boolean

检测QQ号是否符合规则

Parameters

string $str

Returns

boolean

ip()

ip(string  $str) : boolean

判断IP地址是否符合IP的格式,ipv4或ipv6

Parameters

string $str

Returns

boolean

ipv4()

ipv4(string  $str) : boolean

判断IP地址是否是合法的ipv4格式

Parameters

string $str

Returns

boolean

ipv6()

ipv6(string  $str) : boolean

判断IP地址是否是合法的ipv6格式

Parameters

string $str

Returns

boolean

between()

between(float  $value, float  $min, float  $max) : boolean

在两个数之间,不包含这2个数字

Parameters

float $value
float $min
float $max

Returns

boolean

betweenEqual()

betweenEqual(float  $value, float  $min, float  $max) : boolean

在两个数之间,包含这2个数字

Parameters

float $value
float $min
float $max

Returns

boolean

lt()

lt(float  $value, float  $num) : boolean

小于

Parameters

float $value
float $num

Returns

boolean

ltEqual()

ltEqual(float  $value, float  $num) : boolean

小于等于

Parameters

float $value
float $num

Returns

boolean

gt()

gt(float  $value, float  $num) : boolean

大于

Parameters

float $value
float $num

Returns

boolean

gtEqual()

gtEqual(float  $value, float  $num) : boolean

大于等于

Parameters

float $value
float $num

Returns

boolean

equal()

equal(float  $value, float  $num) : boolean

等于

Parameters

float $value
float $num

Returns

boolean

unequal()

unequal(float  $value, float  $num) : boolean

不等于

Parameters

float $value
float $num

Returns

boolean

compare()

compare(string  $valueLeft, string  $operation, string  $valueRight) : boolean

比较

Parameters

string $valueLeft
string $operation
string $valueRight

Returns

boolean

in()

in(float  $value, mixed  $list) : boolean

值在范围内

Parameters

float $value
mixed $list

array | string(1,2,3)

Returns

boolean

notIn()

notIn(float  $value, mixed  $list) : boolean

值不在范围内

Parameters

float $value
mixed $list

array | string(1,2,3)

Returns

boolean

inEnum()

inEnum(float  $value, string  $enumClass) : boolean

值在枚举值范围内

Parameters

float $value
string $enumClass

Returns

boolean

notInEnum()

notInEnum(float  $value, string  $enumClass) : boolean

值不在枚举值范围内

Parameters

float $value
string $enumClass

Returns

boolean

cnIdcard()

cnIdcard(string  $id_card) : boolean

检测中国居民身份证,支持15位和18位

Parameters

string $id_card

Returns

boolean