User.php
1.5 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace app\admin\validate;
use think\Validate;
class User extends Validate
{
/**
* 验证规则
*/
protected $rule = [
'username' => 'require|max:10',
'nickname' => 'require|max:10',
'mobile' => ['require','regex:/^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$/'],
'teach_phone'=> ['regex:/^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$/']
];
/**
* 字段描述
*/
protected $field = [
'username.require' => '用户名不能为空',
'nickname.require' => '昵称不能为空',
'mobile.require' => '手机号不能为空',
'mobile.regex' => '手机号只能为11位,且只能为13,14,15,16,17,18,19开头',
'teach_phone.regex' => '老师手机号只能为11位,且只能为13,14,15,16,17,18,19开头',
];
/**
* 提示消息
*/
protected $message = [
];
/**
* 验证场景
*/
protected $scene = [
'add' => [],
'edit' => ['username','nickname','mobile','teach_phone'],
];
public function __construct(array $rules = [], $message = [], $field = [])
{
$this->field = [
'username' => __('Username'),
'nickname' => __('Nickname'),
'password' => __('Password'),
'email' => __('Email'),
'mobile' => __('Mobile')
];
parent::__construct($rules, $message, $field);
}
}