TP自动验证密码范围
程序员文章站
2022-03-08 14:46:15
验证规则 $validate = new Validate( [ 'user_name' => 'require|mobile', 'password' => 'require|max:16|min:8', 'verify_code' => 'require', 'type' => 'number| ......
验证规则
$validate = new validate( [ 'user_name' => 'require|mobile', 'password' => 'require|max:16|min:8', 'verify_code' => 'require', 'type' => 'number|between:0,1', ], ['phone.require' => '手机号必填', 'phone.mobile' => '手机号格式错误', 'password.require' => '密码不能为空', 'password.max' => '密码设置8-16之间', 'password.min' => '密码设置8-16之间', 'verify_code.require' => '验证码不能为空', 'type.between' => '在0和1之间', ] );
验证方法
if (!$validate->check($request->post())) { $this->apiresult(customerror::operation_succsess, [], $validate->geterror()); }
上一篇: 手机上的首创!小爱同学3.0正式上线