stopPropagation(); $keys = $throwable->validator->errors()->keys(); if (count($keys) > 0) { $msg = $keys[0] . str_replace("validation", "", $throwable->validator->errors()->first($keys[0])); } else { $msg = $throwable->validator->errors()->first(); } return $response->withStatus(200)->withBody(new SwooleStream(json_encode(['code'=>2,'msg'=>$msg]))); } /** * 验证之后 * @param Throwable $throwable * @return bool */ public function isValid(Throwable $throwable): bool { return $throwable instanceof ValidationException; } }