'required', 'avatar' => 'required', 'nickname' => 'required', 'email' => 'required|email', 'mobile' => 'required|mobile', 'code' => 'required', 'invite_code' => 'required', 'scene' => 'required', 'pay_password' => 'required', 'gender' => 'required', 'coin_type' => 'required', 'to_user_id' => 'required', 'password' => 'required', ]; // 当前模型所有错误提示信息 public static $msgs = [ 'required' => ':attribute不能为空', 'string' => ':attribute必须是字符串', 'min' => ':attribute长度不能小于:min位', 'max' => ':attribute长度不能大于:max位', 'exists' => ':attribute不存在', 'rule' => ':attribute格式不正确', ]; // 当前模型所有验证字段 public static $fields = [ 'id' => 'ID', 'avatar' => '头像', 'gender' => '性别', 'nickname' => '昵称', 'mobile' => '手机号码', 'email' => '邮箱地址', 'new_email' => '新邮箱地址', 'new_mobile' => '新手机号码', 'password' => '登录密码', 'pay_password' => '交易密码', 'to_user_id' => '转账用户ID号', 'invite_code' => '邀请码', 'scene' => '验证码类型', 'score' => '积分', 'mid' => '商家', 'coin_type' => '账户类型', 'code' => '验证码', ]; // 当前模型所有验证场景 public static $scenes = [ 'info'=> ['id'], 'save'=> ['mobile','nickname','gender'], 'sms'=> ['mobile','scene'], 'mobile_login'=> ['mobile','code'], 'email_login'=> ['email','code'], 'email_register'=> ['email','code'], 'mobile_register'=> ['mobile','code'], 'email'=> ['email','scene'], 'email_password_login'=> ['email','password'], 'mobile_password_login'=> ['mobile','password'], 'recharge'=> ['usdt'], 'transfer'=> ['money','coin_type','to_user_id'], 'withdraw'=> ['money','coin_type'], 'exchange'=> ['score'], 'payment'=> ['money','coin_type','mid'], 'trade'=> ['pay_password','code'], 'modify_email'=> ['email','new_email'], 'modify_mobile'=> ['mobile','new_mobile'], 'modify_password'=> ['password'], 'reset_password'=> ['password'], 'modify'=> ['nickname','gender'], 'wallet'=> ['trc_url','code'] ]; /** * 验证 * @param $request * @param string $scene * @return int|mixed */ public static function check($request, $scene=''){ $validator = new BaseValidator(self::$rules, self::$msgs, self::$fields, self::$scenes); return $validator->checkParams($request, $scene); } }