Skip to content

Commit

Permalink
feat: 댓글 유효성 검사 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
Sehee-Lee-01 committed Mar 3, 2024
1 parent e2c2cea commit 09f1c05
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package sixgaezzang.sidepeek.comments.dto.request;

import static sixgaezzang.sidepeek.common.util.CommonConstant.MAX_TEXT_LENGTH;
import static sixgaezzang.sidepeek.comments.exception.message.CommentErrorMessage.CONTENT_IS_NULL;
import static sixgaezzang.sidepeek.comments.exception.message.CommentErrorMessage.CONTENT_OVER_MAX_LENGTH;
import static sixgaezzang.sidepeek.comments.exception.message.CommentErrorMessage.IS_ANONYMOUS_IS_NULL;
import static sixgaezzang.sidepeek.comments.util.CommentConstant.MAX_COMMENT_LENGTH;
import static sixgaezzang.sidepeek.common.util.CommonConstant.MIN_ID;

import io.swagger.v3.oas.annotations.media.Schema;
Expand All @@ -12,16 +15,16 @@
@Schema(description = "댓글 생성/수정 요청 정보")
public record CommentRequest(
@Schema(description = "댓글 작성자 식별자", example = "1")
@Min(value = MIN_ID, message = "")
@Min(value = MIN_ID, message = "작성자 id는 " + MIN_ID + "보다 작을 수 없습니다.")
Long ownerId,

@Schema(description = "익명 댓글 여부", example = "false")
@NotNull
@NotNull(message = IS_ANONYMOUS_IS_NULL)
Boolean isAnonymous,

@Schema(description = "댓글 내용", example = "우와 이 프로젝트 대박인데요?")
@Size(max = MAX_TEXT_LENGTH, message = "")
@NotBlank
@Size(max = MAX_COMMENT_LENGTH, message = CONTENT_OVER_MAX_LENGTH)
@NotBlank(message = CONTENT_IS_NULL)
String content
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package sixgaezzang.sidepeek.comments.exception.message;

import static sixgaezzang.sidepeek.comments.util.CommentConstant.MAX_COMMENT_LENGTH;

public class CommentErrorMessage {
// isAnonymous
public static final String IS_ANONYMOUS_IS_NULL = "익명 댓글 여부를 입력해주세요.";

// content
public static final String CONTENT_IS_NULL = "댓글 내용을 입력해주세요.";
public static final String CONTENT_OVER_MAX_LENGTH = "댓글은 " + MAX_COMMENT_LENGTH + "자 이하여야 합니다.";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package sixgaezzang.sidepeek.comments.util;

public class CommentConstant {
public static final int MAX_COMMENT_LENGTH = 300;
}

0 comments on commit 09f1c05

Please sign in to comment.