验证规则
$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::PARAMS_ERROR, [], $validate->getError()); }