Add input validation to Employee REST API#42
Open
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
Open
Add input validation to Employee REST API#42devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
Conversation
- Add @notblank and @SiZe annotations to Employee entity fields (firstName, lastName, jobTitle) - Add @Valid annotation to createEmployee endpoint parameter - Add JAXB test dependencies for Java 11 compatibility - Add EmployeeValidationTest with 11 test cases covering null, empty, blank, max-length, and over-max-length inputs Co-Authored-By: Wes Convery <2wconvery@gmail.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Author
End-to-End Test ResultsTested input validation on Validation Tests (6/6 passed)
No escalations. Devin session |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds Bean Validation constraints to the Employee REST API so that invalid input is rejected with a 422 response before reaching the database.
Changes:
@NotBlankand@Size(min=1, max=255)annotations tofirstName,lastName, andjobTitlefields. This rejects null, empty, and whitespace-only values, and enforces a 255-character max length.@Validon thecreateEmployeemethod parameter so Dropwizard triggers validation automatically and returns structured error responses on constraint violations.jaxb-apiandjaxb-runtimeas test-scoped dependencies for Java 11 compatibility.Review & Testing Checklist for Human
POST /employee@NotBlankfromorg.hibernate.validator.constraintsis appropriate for the Dropwizard 1.0.5 / Hibernate Validator 5.x version in useNotes
ConstraintViolationExceptionMapperhandles the error response formatting automatically — no custom exception mapper was needed.@NotBlankannotation covers both null and whitespace-only checks, while@Sizeadds the upper bound constraint.Link to Devin session: https://app.devin.ai/sessions/29e94bdec4d9451283bc8fb83f12be2e
Requested by: @WesternConcrete
Devin Review