IndexValidate.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
<?php
namespace app\api\validate;
use think\Validate;
class IndexValidate extends Validate
{
/**
* 验证规则
*/
protected $rule = [
'service_type' => 'require|in:1,2',
'cart_type' => 'require|in:1,2',
'nickname' => 'require',
'avatar' => 'require',
'realname' => 'require',
'mobile' => 'require|regex:/^1\d{10}$/',
'id_number' => ['require', 'regex' => '^\d{18}$|^\d{17}(X|x)$'],
'code' => 'require',
'id_images' => 'require',
];
/**
* 提示消息
*/
protected $message = [
'service_type.require' => '请选择服务类型',
'service_type.in' => '服务类型参数错误',
'cart_type.require' => '请选择汽车类型',
'nickname.require' => '昵称不能为空',
'avatar.require' => '头像不能为空',
'cart_type.in' => '汽车类型参数错误',
'realname.require' => '请输入真实姓名',
'mobile' => '请输入正确的电话号',
'id_number' => '请输入正确的身份证号',
'code' => '请输入验证码',
'id_images' => '请上传身份证图片',
];
/**
* 验证场景
*/
protected $scene = [
'select_goods' => ['service_type', 'cart_type'],
'login' => ['nickname', 'avatar'],
'apply' => ['realname', 'mobile', 'id_number', 'code', 'id_images'],
];
}