Skip to content

Commit 150a152

Browse files
feat: validating if list is null and added @Valid in controller
1 parent 1d7f5a4 commit 150a152

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

techchallenge/src/main/java/br/com/grupo63/techchallenge/adapter/in/controller/order/OrderController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public AdvanceOrderStatusResponseDTO advanceOrderStatusFromOrderId(@Parameter(de
5252
description = "Registra um pedido a ser realizado, retorna o valor total")
5353
@PostMapping("/criar")
5454
public ResponseEntity<OrderDTO> create(@RequestParam Long clientId,
55-
@RequestBody CreateOrderRequestDTO createOrderRequestDTO) throws NotFoundException {
55+
@Valid @RequestBody CreateOrderRequestDTO createOrderRequestDTO) throws NotFoundException {
5656

5757
return ResponseEntity.ok(useCase.create(createOrderRequestDTO.toDomainDto(clientId)));
5858
}

techchallenge/src/main/java/br/com/grupo63/techchallenge/adapter/in/controller/order/dto/CreateOrderRequestDTO.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public static class Item {
2929
private Long quantity;
3030
}
3131

32+
@NotNull(message = "order.create.items.notEmpty")
3233
@Size(min = 1, message = "order.create.items.notEmpty")
3334
private List<Item> items;
3435

0 commit comments

Comments
 (0)