init: 项目初始代码
This commit is contained in:
54
app/api/validate/Comment.php
Normal file
54
app/api/validate/Comment.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
namespace app\api\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* Class Comment
|
||||
* @package app\api\validate
|
||||
*/
|
||||
class Comment extends Validate
|
||||
{
|
||||
/**
|
||||
* 定义验证规则
|
||||
* 格式:'字段名' => ['规则1','规则2'...]
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => ['require','integer','gt:0'],
|
||||
'page' => ['integer','gt:0'],
|
||||
'size' => ['integer','gt:0'],
|
||||
'site_id|语言版本' => ['integer','gt:0'],
|
||||
'sort|排序' => ['require','integer','gt:0','lt:256'],
|
||||
'avatar|客户头像' => [
|
||||
'fileSize' => 1024 * 1024 * 1,
|
||||
'fileExt' => 'jpg,png,ico',
|
||||
'fileMime' => 'image/jpeg,image/png,image/gif',
|
||||
],
|
||||
'image|评价配图' => [
|
||||
'fileSize' => 1024 * 1024 * 5,
|
||||
'fileExt' => 'jpg,png,bmp,gif,jpeg',
|
||||
'fileMime' => 'image/jpeg,image/png,image/gif'
|
||||
],
|
||||
'nickname|客户昵称' => ['length:1,20'],
|
||||
'comment|评价内容' => ['length:1,1500'],
|
||||
'url|产品链接' => ['length:1,128'],
|
||||
];
|
||||
/**
|
||||
* 定义错误信息
|
||||
* 格式:'字段名.规则名' => '错误信息'
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $message = [];
|
||||
|
||||
protected $scene = [
|
||||
'index' => ['page','size','nickname'],
|
||||
'read' => ['id'],
|
||||
'create' => ['site_id','name','nickname','comment','url','sort'],
|
||||
'update' => ['id','name','nickname','comment','url','sort'],
|
||||
'del' => ['id'],
|
||||
'upload' => ['avatar','image']
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user