User.php
877 字节
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
28
29
30
31
32
33
34
35
36
37
<?php
namespace app\admin\validate;
use think\Validate;
class User extends Validate
{
/**
* 验证规则
*/
protected $rule = [
'username' => 'require|unique:user',
'password' => 'require|regex:\S{32}',
'mobile' => 'require|regex:^1\d{10}$|unique:user',
];
/**
* 提示消息
*/
protected $message = [
'username.require' => '请填写用户名',
'username.unique' => '用户名已存在',
'password.require' => '请填写密码',
'password.regex' => '密码格式错误',
'mobile.require' => '请填写手机号',
'mobile.regex' => '手机号格式错误',
'mobile.unique' => '手机号已存在',
];
/**
* 验证场景
*/
protected $scene = [
'add' => ['username','password','mobile'],
'edit' => [],
];
}