'require|in:mobile,email', 'mobile' => 'regex:^1\d{10}$|requireIf:type,mobile', 'email' => 'email|requireIf:type,email', 'captcha' => 'require', 'newpassword' => 'require|length:6,30', ]; /** * 提示消息 */ protected $message = [ 'type.require' => '验证类型不能为空', 'type.in' => '验证类型只能是手机号或邮箱', 'mobile.regex' => '手机号格式不正确', 'mobile.requireIf' => '手机号不能为空', 'email.email' => '邮箱格式不正确', 'email.requireIf' => '邮箱不能为空', 'captcha.require' => '验证码不能为空', 'newpassword.require' => '新密码不能为空', 'newpassword.length' => '新密码长度必须在6-30个字符之间' ]; /** * 验证场景 */ protected $scene = [ 'cancel' => ['type', 'mobile', 'email', 'captcha'], 'resetpwd' => ['type', 'mobile', 'email', 'newpassword', 'captcha'], ]; }