chengkun
2025-08-06 b54e02d98e42ae73071e3c01e59f12671d13d06a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
namespace app\admin\validate;
 
use think\Validate;
 
class Administrators extends Validate {
    
     
    protected $rule = [
        'user_name' => 'require|unique:administrators,user_name',
        'pwd' => 'regexo:/^.{6,18}$/|regext:/^.*?[\d]+.*$/|regexth:/^.*?[A-Za-z].*$/',
        'real_name' => 'require',
    ];
    protected $message = [
        'user_name.require' => '请填写账号',
        'user_name.unique' => '账号已存在',
        'pwd.regexo' => '密码必须在6-18位',
        'pwd.regext' => '密码必须包含数字',
        'pwd.regexth' => '密码必须包含字母',
        'real_name.require' => '请填写管理员姓名',
    ];
    protected $scene = [
        'edit'  =>  ['pwd','real_name'],/////编辑情况下只验证密码的复杂程度////////
    ]; 
 
 
}