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

64 lines
2.4 KiB
PHP

<?php
declare (strict_types = 1);
namespace app\api\validate;
use think\Validate;
class SoftManual extends Validate
{
/**
* 定义验证规则
* 格式:'字段名' => ['规则1','规则2'...]
*
* @var array
*/
protected $rule = [
'id' => ['require','integer','gt:0'],
'page' => ['integer','gt:0'],
'size' => ['integer','gt:0'],
'site_id|语言版本' => ['require','integer','gt:0'],
'file_type_id|文件分类' => ['integer','gt:0'],
'name|下载名称' => ['length:1,50','unique:soft_manual,name^site_id^platform_id'],
'introduce|下载介绍' => ['length:1,255'],
'support|支持型号' => ['length:1,255'],
'os|操作系统' => ['length:1,60'],
'sort|排序' => ['require','between:1,255'],
'download_count|下载次数' => ['integer','gt:0'],
// 'image|预览图' => [
// 'fileSize' => 1024 * 1024 * 10,
// 'fileExt' => 'jpg,png,gif',
// 'fileMime' => 'image/jpeg,image/png,image/gif'
// ],
// 'file|驱动文件' => [
// 'fileSize' => 1024 * 1024 * 100,
// 'fileExt' => 'xls,xlsx,jpg,png,docx,doc,rar,zip,pdf,chm',
// 'fileMime' => 'image/jpeg,image/png,image/gif,application/x-rar-compressed,application/zip,application/pdf,audio/ogg,text/plain,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-htmlhelp'
// ],
];
/**
* 定义错误信息
* 格式:'字段名.规则名' => '错误信息'
*
* @var array
*/
protected $message = [
'name.length' => '下载名称不能超过50个字符',
'introduce.length' => '下载介绍不能超过255个字符',
'support.length' => '支持型号不能超过255个字符',
'os.length' => '操作系统不能超过60个字符',
];
protected $scene = [
'index' => [''],
'read' => ['id'],
'create' => ['site_id','file_type_id','name','introduce','support','os','sort'],
'update' => ['id','file_type_id','name','introduce','support','os','sort'],
'del' => ['id'],
'changeStatus' => ['id','status'],
// 'upload' => ['image','file']
];
}