Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ public class UserController {
// TODO 진짜 돌았냐? POST로 바꿔라
@GetMapping("/auth/check")
public ResponseEntity<ApiResponse<CheckDuplicatedEmailResponse, Void>> checkDuplicatedEmail(
@RequestBody CheckDuplicatedEmailRequest checkDuplicatedEmailRequest
@RequestParam String email
) {
Comment on lines +34 to 35
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

쿼리 파라미터로 바뀌면서 입력 검증이 빠졌습니다 — 필수/형식 검증 추가 권장

기존 @RequestBody @Valid 경로에서 넘어오던 Bean Validation이 사라졌을 가능성이 큽니다. 최소한 공백/형식 검증을 파라미터에 직접 부여해 동일한 계약을 유지하세요.

아래처럼 수정 제안드립니다.

-            @RequestParam String email
+            @RequestParam
+            @NotBlank(message = "이메일은 필수 입력 값입니다.")
+            @Email(message = "유효하지 않은 이메일 형식입니다.")
+            String email

다음 스크립트로 프로젝트가 jakarta.validation 또는 javax.validation 중 무엇을 사용 중인지, 그리고 컨트롤러 메서드 파라미터 검증이 활성화되어 있는지 확인해 주세요.


🏁 Script executed:

#!/bin/bash
# jakarta/javax 사용 현황
rg -nP 'import\s+(jakarta|javax)\.validation' -C1

# @Validated 사용 여부(메서드/파라미터 검증용)
rg -nP '@Validated' -g 'src/**/controller/**.java' -C2

# 이 엔드포인트 사용처(클라이언트/문서 영향도 확인)
rg -nP '/api/v1/auth/check\b' -C2

Length of output: 1441


UserController 클래스에 @validated 추가 및 이메일 파라미터 검증 어노테이션 적용
파라미터 검증이 활성화되어 있지 않으므로, jakarta.validation 제약(@notblank, @Email)을 사용하려면 클래스에 @Validated를 추가하고 이메일 파라미터에 다음과 같이 어노테이션을 부여하세요:

diff --git a/src/main/java/inha/gdgoc/domain/user/controller/UserController.java b/src/main/java/inha/gdgoc/domain/user/controller/UserController.java
index e69de29..abcd123 100644
--- a/src/main/java/inha/gdgoc/domain/user/controller/UserController.java
+++ b/src/main/java/inha/gdgoc/domain/user/controller/UserController.java
@@ -1,7 +1,11 @@
 package inha.gdgoc.domain.user.controller;

+import org.springframework.validation.annotation.Validated;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.Email;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;

 @RestController
 @RequestMapping("/api/v1/auth")
+@Validated
 public class UserController {
     @GetMapping("/check")
-    public ResponseEntity<?> checkEmail(@RequestParam String email) {
+    public ResponseEntity<?> checkEmail(
+        @RequestParam
+        @NotBlank(message = "이메일은 필수 입력 값입니다.")
+        @Email(message = "유효하지 않은 이메일 형식입니다.")
+        String email
+    ) {
         // …
     }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@RequestParam String email
) {
package inha.gdgoc.domain.user.controller;
import org.springframework.validation.annotation.Validated;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Email;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api/v1/auth")
@Validated
public class UserController {
@GetMapping("/check")
public ResponseEntity<?> checkEmail(
@RequestParam
@NotBlank(message = "이메일은 필수 입력 값입니다.")
@Email(message = "유효하지 않은 이메일 형식입니다.")
String email
) {
// …
}
}
🤖 Prompt for AI Agents
In src/main/java/inha/gdgoc/domain/user/controller/UserController.java around
lines 34-35, method parameter validation is not enabled: add the Spring/JSR
validation support by annotating the controller class with @Validated and
annotate the email parameter with @NotBlank and @Email (importing
jakarta.validation.constraints.NotBlank and
jakarta.validation.constraints.Email). Ensure the controller class imports
org.springframework.validation.annotation.Validated and the parameter uses the
validation annotations so the framework enforces the constraints at runtime.

CheckDuplicatedEmailResponse response = userService.isExistsByEmail(checkDuplicatedEmailRequest);
CheckDuplicatedEmailResponse response =
userService.isExistsByEmail(new CheckDuplicatedEmailRequest(email));

return ResponseEntity.ok(ApiResponse.ok(USER_EMAIL_DUPLICATION_RETRIEVED_SUCCESS, response));
}
Expand Down
Loading