53 lines
1.7 KiB
PHP
53 lines
1.7 KiB
PHP
<?php
|
|
namespace app\api\validate;
|
|
|
|
use think\Validate;
|
|
|
|
class Base extends Validate
|
|
{
|
|
/**
|
|
* 定义验证规则
|
|
* 格式:'字段名' => ['规则1','规则2'...]
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $rule = [
|
|
'icon|图标' => [
|
|
'fileSize' => 1024 * 1024 * 5,
|
|
'fileExt' => 'jpg,png,bmp,gif,jpeg',
|
|
'fileMime' => 'image/jpeg,image/png,image/gif'
|
|
],
|
|
'image|图片' => [
|
|
'fileSize' => 1024 * 1024 * 5,
|
|
'fileExt' => 'jpg,png,ico,jpeg',
|
|
'fileMime' => 'image/jpeg,image/png,image/gif'
|
|
],
|
|
'file|文件' => [
|
|
'fileSize' => 1024 * 1024 * 10,
|
|
'fileExt' => 'xls,xlsx,jpg,png,docx,doc',
|
|
'fileMime' => 'application/vnd.ms-excel,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.openxmlformats-officedocument.spreadsheetml.sheet'
|
|
],
|
|
'driver|驱动' => [
|
|
'fileSize' => 1024 * 1024 * 10,
|
|
'fileExt' => 'xls,xlsx,jpg,png,docx,doc,rar,zip',
|
|
'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'
|
|
],
|
|
];
|
|
|
|
/**
|
|
* 定义错误信息
|
|
* 格式:'字段名.规则名' => '错误信息'
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $message = [];
|
|
|
|
protected $scene = [
|
|
'file' => ['file'],
|
|
'image' => ['image'],
|
|
'icon' => ['icon'],
|
|
'driver' => ['driver'],
|
|
];
|
|
|
|
}
|