lihai-oa/app/project/validate/ProjectCheck.php

36 lines
1.3 KiB
PHP
Raw Normal View History

2023-10-24 15:17:16 +08:00
<?php
namespace app\project\validate;
use think\Validate;
2023-10-31 10:12:16 +08:00
use think\facade\Db;
2023-10-24 15:17:16 +08:00
class ProjectCheck extends Validate
{
protected $rule = [
2023-10-31 10:12:16 +08:00
'name' => 'require|unique:project',
'start_time' => 'require',
'end_time' => 'require',
'director_uid' => 'require',
'content' => 'require',
'code' => 'alphaNum|length:5,10|unique:project',
2023-10-31 10:23:32 +08:00
'id' => 'require'
2023-10-24 15:17:16 +08:00
];
protected $message = [
'name.require' => '项目名称不能为空',
2023-10-31 10:12:16 +08:00
'name.unique' => '项目已存在',
'start_time.require' => '项目开始时间不能为空',
'end_time.require' => '项目结束时间不能为空',
'director_uid.require' => '项目负责人不能为空',
'content.require' => '项目简介不能为空',
2023-10-24 15:17:16 +08:00
'code.alphaNum' => '项目代码只能为5至10为字母和数字',
'code.length' => '项目代码只能为5至10为字母和数字',
'code.unique' => '同样的项目代码已经存在',
'id.require' => '缺少更新条件',
];
protected $scene = [
2023-10-31 10:12:16 +08:00
'add' => ['name','start_time','end_time','director_uid','content','code'],
2023-10-31 10:23:32 +08:00
'edit' => ['id']
2023-10-24 15:17:16 +08:00
];
2023-10-31 10:12:16 +08:00
2023-10-24 15:17:16 +08:00
}