这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@sandipk09roy-pixel
Copy link
Contributor

Summary

This pull request introduces a Spring Boot module that demonstrates custom validation using @Valid, @RequestBody, and BindingResult. It provides a reproducible example for students and collaborators to understand field-level validation and structured error handling in REST APIs.

Features

  • UserDTO with annotations: @Email, @Size, @NotBlank, @Min
  • UserController with validation logic and error response formatting
  • LogbackPing class to ensure compatibility with logback-core packaging
  • Entry point via SpringBootCustomValidationApplication.java
  • Compatible with Spring Boot 3.2.5 and Java 21

How to Test

curl -X POST http://localhost:8081/register \
     -H "Content-Type: application/json" \
     -d "{\"email\":\"invalid-email\",\"password\":\"short\"}"
### Expected response:

[
  "Please provide a valid email address.",
  "Name must not be blank.",
  "Age must be at least 18."
]

### Notes
- No external configuration required
- Designed for onboarding and reproducibility
- Ideal for student learning and collaborative extension

@sandipk09roy-pixel
Copy link
Contributor Author

Refactored package structure to com.baeldung.validation.custommessage as suggested. All classes and tests have been moved, and package declarations updated. Let me know if further adjustments are needed.

@eric-martin eric-martin merged commit b02e6a2 into eugenp:master Oct 25, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants