first commit
This commit is contained in:
45
app/common/validate/system/Department.php
Normal file
45
app/common/validate/system/Department.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\common\validate\system;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class Department extends Validate
|
||||
{
|
||||
/**
|
||||
* 定义验证规则
|
||||
* 格式:'字段名' => ['规则1','规则2'...]
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $rule = [
|
||||
'pid' => 'notEqId',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 定义错误信息
|
||||
* 格式:'字段名.规则名' => '错误信息'
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $message = [
|
||||
'pid.notEqId' => '选择上级分类错误!',
|
||||
];
|
||||
|
||||
/**
|
||||
* 自定义验证规则
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $post
|
||||
* @return bool
|
||||
*/
|
||||
protected function notEqId($value, $rule, $post): bool
|
||||
{
|
||||
if ($value == $post['id']) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user