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
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'com.fasterxml.jackson.core:jackson-databind'
implementation 'org.springframework.boot:spring-boot-starter-validation'
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

Validate controller setup for @max on @RequestParam/@PathVariable

Starter alone wires the Validator, but simple type constraints require @validated on the controller (or method) for MVC/WebFlux binding. Also, if you rely on method-level validation for services, add @EnableMethodValidation on a configuration class.

Run the following to locate usages and verify annotations:

If any controllers using @RequestParam/@PathVariable constraints lack @validated, I can propose a small patch.


🏁 Script executed:

#!/bin/bash
# Show all @Max usages with context
rg -n -A 5 -B 5 '@Max\s*\('

echo
echo "Controllers annotated with @Validated:"
rg -n '@(org\.springframework\.validation\.annotation\.)?Validated'

echo
echo "Presence of @EnableMethodValidation (optional, for method-level validation):"
rg -n '@(org\.springframework\.validation\.annotation\.)?EnableMethodValidation'

Length of output: 1862


Annotate controllers with @validated to enforce @max constraints

The PostController#getPostList method applies @Max(30) to a @RequestParam but the controller isn’t annotated with Spring’s method‐validation support, so that constraint won’t be enforced at runtime. Add @Validated on the class (or method) level. If you also rely on service‐layer method validation, enable it via @EnableMethodValidation in a configuration class.

• File: src/main/java/naughty/tuzamate/domain/post/controller/PostController.java
– Add @Validated to the controller class.
• (Optional) File: any @Configuration class
– Add @EnableMethodValidation to activate service‐layer method validation.

Suggested diff:

--- a/src/main/java/naughty/tuzamate/domain/post/controller/PostController.java
+++ b/src/main/java/naughty/tuzamate/domain/post/controller/PostController.java
@@
- @RestController
+ @RestController
+ @Validated
  @RequestMapping("/boards/{boardType}/posts")
  public class PostController {
      …
📝 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
implementation 'org.springframework.boot:spring-boot-starter-validation'
--- a/src/main/java/naughty/tuzamate/domain/post/controller/PostController.java
+++ b/src/main/java/naughty/tuzamate/domain/post/controller/PostController.java
@@
- @RestController
+ @RestController
+ @Validated
@RequestMapping("/boards/{boardType}/posts")
public class PostController {
🤖 Prompt for AI Agents
In src/main/java/naughty/tuzamate/domain/post/controller/PostController.java
around the class declaration, the controller is missing Spring’s @Validated so
method-level javax validation (e.g. @Max on @RequestParam in getPostList) won’t
be enforced; add the @Validated annotation to the controller class and import
org.springframework.validation.annotation.Validated; additionally, if you want
service-layer method validation enabled, add @EnableMethodValidation to a
@Configuration class (and import
org.springframework.validation.annotation.EnableMethodValidation) to activate
method validation across beans.


compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.mysql:mysql-connector-j'
Expand Down
Loading