init
This commit is contained in:
40
app/mobile/validate/Pinglun.php
Executable file
40
app/mobile/validate/Pinglun.php
Executable file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
namespace app\mobile\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class Pinglun extends Validate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
['pid', 'require', 'pid不能为空'],
|
||||
['cid', 'require', 'cid不能为空'],
|
||||
['typeid', 'require', 'typeid不能为空'],
|
||||
['content', 'require|check_value:content', '内容不能为空'],
|
||||
];
|
||||
|
||||
protected $scene = [
|
||||
'add' => ['pid', 'cid', 'typeid', 'content'],
|
||||
];
|
||||
|
||||
protected function check_value($value, $rule)
|
||||
{
|
||||
switch ($rule) {
|
||||
case 'content':
|
||||
$length = utf8_strlen($value);
|
||||
if ($length < 6 || $length > 100) {
|
||||
return '评论必须在6-100个字之间';
|
||||
}
|
||||
|
||||
return true;
|
||||
break;
|
||||
case '':
|
||||
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user