Add input validation to REST API request DTOs#203
Open
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
Open
Add input validation to REST API request DTOs#203devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
Conversation
- Add @NotNull, @notblank, @notempty, @positive, @Valid constraints to all request DTOs across order, consumer, restaurant, and courier service API modules - Add cascading @Valid on nested objects (PersonName, Address, RestaurantMenuDTO, MenuItemDTO, LineItem) - Add @Valid before @RequestBody in all controller methods that accept request DTOs - Add MethodArgumentNotValidException handler in GlobalExceptionHandler to return structured 400 responses with field-level error details 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:
|
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 (JSR 380) annotations to all REST API request DTOs across the FTGO monolith. This ensures that invalid requests are rejected early at the controller layer with structured error responses, rather than propagating bad data into the service/domain layer.
Changes by module
ftgo-common (shared value objects):
PersonName:@NotBlankonfirstName,lastNameAddress:@NotBlankonstreet1,city,state,zipftgo-order-service-api:
CreateOrderRequest:@PositiveonconsumerId/restaurantId,@NotNull @NotEmpty @ValidonlineItemsCreateOrderRequest.LineItem:@NotBlankonmenuItemId,@PositiveonquantityReviseOrderRequest:@NotNull @NotEmptyonrevisedLineItemQuantitiesOrderAcceptance:@NotNullonreadyByftgo-consumer-service-api:
CreateConsumerRequest:@NotNull @Validonnameftgo-restaurant-service-api:
CreateRestaurantRequest:@NotBlankonname,@NotNull @Validonmenu/addressRestaurantMenuDTO:@NotNull @NotEmpty @ValidonmenuItemsMenuItemDTO:@NotBlankonid/name,@NotNullonpriceftgo-courier-service-api:
CreateCourierRequest:@NotNull @Validonname/addressControllers (all 4 services):
@Validbefore@RequestBodyon all POST endpoints that accept request DTOsGlobalExceptionHandler:
MethodArgumentNotValidExceptionhandler returning 400 with field-level error detailsNo new dependencies required —
hibernate-validatoris already transitively available viaspring-boot-starter-web(Spring Boot 2.0.3).Review & Testing Checklist for Human
POST /orderswith emptylineItems) and confirm a 400 response with field-level error messagesfirstNameinPersonName) and confirm cascading validation worksMethodArgumentNotValidExceptionmatches expectations for any API clientsNotes
OrderControllerTestare a Mockito compatibility issue unrelated to this change (verified by running tests on the base branch).CourierAvailabilityandCourierLocationUpdatewere not annotated as their primitive fields (boolean,double) have sensible defaults and don't benefit from null/blank checks.Link to Devin session: https://app.devin.ai/sessions/7f478653ae6641cab0f3e2c8aeeefb07
Requested by: @WesternConcrete
Devin Review