This commit is contained in:
Your Name
2026-03-11 09:49:47 +08:00
parent 02ae537b4c
commit 38ad60f4bb
290 changed files with 36917 additions and 123 deletions
+11 -38
View File
@@ -27,47 +27,20 @@ use app\common\validate\BaseValidate;
class SetUserInfoValidate extends BaseValidate
{
protected $rule = [
'field' => 'require|checkField',
'value' => 'require',
'avatar' => 'string',
'phone' => 'regex:/^1[3-9]\d{9}$/|',
'nickname' => 'string|max:50',
'gender' => 'in:0,1',
'age' => 'integer|between:0,150',
'patient_name' => 'string|max:50'
];
protected $message = [
'field.require' => '参数缺失',
'value.require' => '值不存在',
'phone.regex' => '手机号格式不正确',
'nickname.max' => '昵称不能超过50个字符',
'gender.in' => '性别参数错误',
'age.between' => '年龄必须在0-150之间',
'patient_name.max' => '姓名不能超过50个字符'
];
/**
* @notes 校验字段内容
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author 段誉
* @date 2022/9/21 17:01
*/
protected function checkField($value, $rule, $data)
{
$allowField = [
'nickname', 'account', 'sex', 'avatar', 'real_name',
];
if (!in_array($value, $allowField)) {
return '参数错误';
}
if ($value == 'account') {
$user = User::where([
['account', '=', $data['value']],
['id', '<>', $data['id']]
])->findOrEmpty();
if (!$user->isEmpty()) {
return '账号已被使用!';
}
}
return true;
}
}