diff --git a/src/main/java/com/telepigeon/server/controller/WorryController.java b/src/main/java/com/telepigeon/server/controller/WorryController.java index 8559b0e..1af739d 100644 --- a/src/main/java/com/telepigeon/server/controller/WorryController.java +++ b/src/main/java/com/telepigeon/server/controller/WorryController.java @@ -4,6 +4,7 @@ import com.telepigeon.server.dto.worry.request.WorryCreateDto; import com.telepigeon.server.dto.worry.response.WorriesDto; import com.telepigeon.server.service.worry.WorryService; +import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @@ -29,7 +30,7 @@ public ResponseEntity getWorries( public ResponseEntity createWorry( @UserId final Long userId, @PathVariable final Long roomId, - @RequestBody final WorryCreateDto request + @RequestBody @Valid final WorryCreateDto request ) { worryService.createWorry(userId, roomId, request); return ResponseEntity.created(URI.create("/rooms/"+ roomId + "/worries")).build(); diff --git a/src/main/java/com/telepigeon/server/dto/worry/request/WorryCreateDto.java b/src/main/java/com/telepigeon/server/dto/worry/request/WorryCreateDto.java index 7e59f66..785441c 100644 --- a/src/main/java/com/telepigeon/server/dto/worry/request/WorryCreateDto.java +++ b/src/main/java/com/telepigeon/server/dto/worry/request/WorryCreateDto.java @@ -1,10 +1,16 @@ package com.telepigeon.server.dto.worry.request; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.Size; + import java.util.List; public record WorryCreateDto ( + @NotBlank String name, + @NotBlank String content, + @Size(min = 1) List times ) { }