40 lines
994 B
PHP
Executable File
40 lines
994 B
PHP
Executable File
<?php
|
|
namespace app\usmobile\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;
|
|
}
|
|
}
|
|
} |