pan; } public function rules(Request $request) { switch ($request->pan) { case '1': return [ 'firstname' => 'required|max:20|regex:/\p{Han}/u', 'gj_num' => 'required|max:50|alpha_dash', 'phone' => 'required|regex:/^1[345789][0-9]{9}$/', 'note' => 'max:50', ]; case '0': return [ 'firstname' => 'required|max:20|regex:/\p{Han}/u', 'gj_num' => 'required|max:50|alpha_dash', 'hk-name' => 'required|max:20|regex:/\p{Han}/u', 'hk-date' => 'nullable|date_format:"Y-m-d"', 'hk-num' => 'required|min:0.01', 'title' => 'nullable|max:50|regex:/\p{Han}/u', 'ns-name' => 'required|max:20|regex:/\p{Han}/u', 'ns-num' => ['required'], 'ns-hang' => ['nullable', 'regex:/\p{Han}/u'], 'ns-account' => ['nullable', 'regex:/^([1-9])(\d|\d|\d)$/'], 'sj-name' => ['required', 'max:20', 'regex:/\p{Han}/u'], 'phone' => 'required|regex:/^1[345789][0-9]{9}$/', 'note' => 'max:50', ]; default: return []; } } public function messages() { return [ 'required' => '这是一个必填项哦!', 'alpha_dash' => '格式不正确哦', 'firstname.regex' => '请输入汉字', 'firstname.max' => '最大只能20个字', 'gj_num.max' => '最多只能50个字', 'hk-date.date_format' => '时间格式错误', // 'hk-num.numeric' => '请输入数字', 'title.max' => '最多输入50个字', 'title.regex' => '包含非法字符(请输入汉字)', 'ns-name.max' => '只能输入20个字哦', 'ns-name.regex' => '含有非法字符(请输入汉字)', // 'ns-num.regex' => '纳税人识别号格式出错!', 'ns-hang.regex' => '银行名称填写出错', 'ns-account.regex' => '银行账号填写出错!请检查', 'sj-name.max' => '只能输入20个字哦', 'sj-name.regex' => '包含非法字符(请填写汉字)', 'note.max' => '最好只能留言50个字哦', 'phone.regex' => '手机号码格式错误', ]; } /* * 验证规则二 * * */ public function ruless() { } /* * 自定义错误信息二 */ public function messagess() { } }