data_center/app/common/validate/user/UserValidate.php

61 lines
1.9 KiB
PHP

<?php
namespace app\common\validate\user;
use app\common\enum\notice\NoticeEnum;
use app\common\validate\BaseValidate;
class UserValidate extends BaseValidate
{
protected $rule = [
'id' => 'require',
'phone' => 'require|mobile|unique:user',
'code' => 'require',
'age' => 'number|gt:0',
'gender' => 'in:0,1,2',
'real_name' => 'chs|length:2,25',
'id_card' => 'idCard',
'province' => 'number',
'city' => 'number',
'area' => 'number',
'street' => 'number',
'village' => 'number',
'brigade' => 'number',
];
protected $message = [
'id.require' => '请选择用户',
'phone.require' => '请输入手机号码',
'phone.mobile' => '请输入正确的手机号码',
'phone.unique' => '该手机号码已注册',
'code.require' => '请输入验证码',
'age.number' => '年龄必须是数字',
'age.gt' => '年龄必须大于0',
'gender.in' => '用户性别值错误',
'real_name.chs' => '真实姓名必须是汉字',
'real_name.length' => '真实姓名长度必须大于2个汉字且不得超过25个汉字',
'id_card.idCard' => '身份证号码不正确',
'province.number' => '省份编码值错误',
'city.number' => '城市编码值错误',
'area.number' => '区县编码值错误',
'street.number' => '镇街编码值错误',
'village.number' => '村社编码值错误',
'brigade.number' => '小组编码值错误',
];
public function sceneDetail(): UserValidate
{
return $this->only(['id']);
}
public function sceneChangeMobile(): UserValidate
{
return $this->only(['phone','code']);
}
public function sceneEdit(): UserValidate
{
return $this->only(['age','gender','real_name','id_card','province','city','area','street','village','brigade','address']);
}
}