You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
1.7 KiB
93 lines
1.7 KiB
<?php
|
|
|
|
namespace app\admin\validate;
|
|
|
|
use think\Validate;
|
|
|
|
class AdminBaseValidate extends Validate
|
|
{
|
|
|
|
// 校验是否是 整数 包含字符串 大于0
|
|
public function checkNumberIntBg($value, $rule, $data=[])
|
|
{
|
|
if(!is_numeric($value)){
|
|
return false;
|
|
}
|
|
|
|
if(ceil($value) != $value){
|
|
return false;
|
|
}
|
|
|
|
if($value <= 0){
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
// 校验是否是 整数 包含字符串 大于0
|
|
public function checkNumberIntAt($value, $rule, $data=[])
|
|
{
|
|
if(!is_numeric($value)){
|
|
return false;
|
|
}
|
|
|
|
if(ceil($value) != $value){
|
|
return false;
|
|
}
|
|
|
|
if($value < 0){
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
// 校验是否是 数字 包含 小数 字符串 大于 0
|
|
public function checkNumberFloatBg($value, $rule, $data=[])
|
|
{
|
|
if(!is_numeric($value)){
|
|
return false;
|
|
}
|
|
|
|
if($value <= 0){
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
// 必传 包含0的情况
|
|
public function checkStatusRequire($value, $rule, $data=[])
|
|
{
|
|
if(!isset($data['status'])){
|
|
return false;
|
|
}
|
|
|
|
if(!is_numeric($value)){
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
// 是否是字符串
|
|
public function checkIsString($value, $rule, $data=[])
|
|
{
|
|
return is_string($value);
|
|
}
|
|
public function checkInRequire($value, $rule, $data=[])
|
|
{
|
|
if(!isset($data['channel_type'])){
|
|
return false;
|
|
}
|
|
|
|
if(!in_array($value,$rule)){
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
}
|