Files
ntonpower/app/api/validate/Faq.php
2026-10-14 14:00:29 +08:00

46 lines
1.2 KiB
PHP

<?php
namespace app\api\validate;
use think\Validate;
/**
* Class Faq
* @package app\api\validate
*/
class Faq 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'],
'faq_type_id|问题分类' => ['integer','gt:0'],
'question|回答问题' => ['length:1,150','require','unique:faq,question^site_id^platform_id'],
'answer|回答内容' => ['length:1,3000'],
'sort|排序' => ['between:1,255'],
];
/**
* 定义错误信息
* 格式:'字段名.规则名' => '错误信息'
*
* @var array
*/
protected $message = [];
protected $scene = [
'index' => ['page','size','answer'],
'read' => ['id'],
'create' => ['site_id','faq_type_id','question','answer','sort'],
'update' => ['id','faq_type_id','question','answer','sort'],
'del' => ['id'],
];
}