extend/alidayu/top/RequestCheckUtil.php
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
/**
* API入参静态检查类
* 可以对API的参数类型、长度、最大值等进行校验
*
**/
class RequestCheckUtil
{
/**
* 校验字段 fieldName 的值$value非空
*
**/
public static function checkNotNull($value,$fieldName) {
if(self::checkEmpty($value)){
throw new Exception("client-check-error:Missing Required Arguments: " .$fieldName , 40);
}
}
/**
* 检验字段fieldName的值value 的长度
*
**/
public static function checkMaxLength($value,$maxLength,$fieldName){
if(!self::checkEmpty($value) && mb_strlen($value , "UTF-8") > $maxLength){
throw new Exception("client-check-error:Invalid Arguments:the length of " .$fieldName . " can not be larger than " . $maxLength . "." , 41);
}
}
/**
* 检验字段fieldName的值value的最大列表长度
*
**/
public static function checkMaxListSize($value,$maxSize,$fieldName) {
if(self::checkEmpty($value))
return ;
$list=preg_split("/,/",$value);
if(count($list) > $maxSize){
throw new Exception("client-check-error:Invalid Arguments:the listsize(the string split by \",\") of ". $fieldName . " must be less than " . $maxSize . " ." , 41);
}
}
/**
* 检验字段fieldName的值value 的最大值
*
**/
public static function checkMaxValue($value,$maxValue,$fieldName){
if(self::checkEmpty($value))
return ;
self::checkNumeric($value,$fieldName);
if($value > $maxValue){
throw new Exception("client-check-error:Invalid Arguments:the value of " . $fieldName . " can not be larger than " . $maxValue ." ." , 41);
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。