coupon-admin/app/validate/Comment.php

28 lines
903 B
PHP

<?php
namespace app\validate;
use think\Validate;
use app\model\Comment as CommentModel;
class Comment extends Validate
{
protected $rule = [
'comment|评论内容' => 'require|max:1024',
'user_code|用户' => 'require|length:32',
'url|图片文件地址' => 'length:0,255',
'type|类型' => 'require|checkType',
'lng|定位信息' => 'require',
'lat|定位信息' => 'require',
'location|位置信息' => 'length:0,200',
];
protected $scene = [
'edit_password' => ['old_password', 'password', 'confirm_password'], //修改密码
];
protected function checkType($value,$rule,$data=[])
{
return isset(CommentModel::allType()[$value]) ? true : '评论类型错误';
}
}