From 412992dfec6ce3a271fc84b648f9a1e1ffeaf407 Mon Sep 17 00:00:00 2001 From: 101 Date: Thu, 29 Feb 2024 15:20:36 +0900 Subject: [PATCH] =?UTF-8?q?validation=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/content/api/DocumentContentController.java | 3 ++- .../daemawiki/domain/content/dto/WriteContentRequest.java | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/example/daemawiki/domain/content/api/DocumentContentController.java b/src/main/java/com/example/daemawiki/domain/content/api/DocumentContentController.java index 187ebc9f..b03093e4 100644 --- a/src/main/java/com/example/daemawiki/domain/content/api/DocumentContentController.java +++ b/src/main/java/com/example/daemawiki/domain/content/api/DocumentContentController.java @@ -4,6 +4,7 @@ import com.example.daemawiki.domain.content.dto.WriteContentRequest; import com.example.daemawiki.domain.content.service.AddContentTable; import com.example.daemawiki.domain.content.service.WriteContent; +import jakarta.validation.Valid; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; import reactor.core.publisher.Mono; @@ -21,7 +22,7 @@ public DocumentContentController(WriteContent writeContentService, AddContentTab @PatchMapping @ResponseStatus(HttpStatus.NO_CONTENT) - public Mono writeContent(@RequestBody WriteContentRequest request) { + public Mono writeContent(@Valid @RequestBody WriteContentRequest request) { return writeContentService.execute(request); } diff --git a/src/main/java/com/example/daemawiki/domain/content/dto/WriteContentRequest.java b/src/main/java/com/example/daemawiki/domain/content/dto/WriteContentRequest.java index bec0559d..eb1812c5 100644 --- a/src/main/java/com/example/daemawiki/domain/content/dto/WriteContentRequest.java +++ b/src/main/java/com/example/daemawiki/domain/content/dto/WriteContentRequest.java @@ -1,9 +1,16 @@ package com.example.daemawiki.domain.content.dto; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + public record WriteContentRequest( + @NotBlank(message = "문서의 id를 입력해주세요.") String documentId, + @NotBlank(message = "내용을 추가하고 싶은 index를 입력해주세요.") String index, + @NotNull(message = "null은 내용이 될 수 없습니다.") String content, + @NotNull(message = "문서의 버전을 입력해주세요.") Integer version ) { }