MemberValidate.php
1.4 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
<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 小夏 < 449134904@qq.com>
// +----------------------------------------------------------------------
namespace app\portal\validate;
use think\Validate;
class MemberValidate extends Validate
{
protected $rule = [
'name' => 'require',
'tel' => 'require|regex:/^[1][3,4,5,7,8][0-9]{9}$/',
'card_num' => 'require|min:15',
];
protected $message = [
'name.require' => '姓名不为空!',
'tel.require' => '手机号不能为空!',
'tel.regex' => '手机号格式不正确!',
'card_num.require' => '身份证号不为空!',
'card_num.min' => '身份证号格式不正确!',
];
protected $scene = [
'isset'=>['tel.regex','card_num.min']
];
// edit 验证场景定义
public function sceneIsset()
{
return $this->only(['tel','card_num'])
->remove('tel', 'require')
->remove('card_num', 'require')
;
}
}