Skip to content

Commit

Permalink
feat: 라벨 인원수 음수 예외 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
yeonsu00 committed Nov 27, 2024
1 parent db48159 commit 4146da5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/postman/bottler/label/domain/Label.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.Getter;
import postman.bottler.label.dto.response.LabelResponseDTO;
import postman.bottler.label.exception.InvalidLabelException;

@Getter
public class Label {
Expand All @@ -23,13 +24,22 @@ private Label(String imageUrl, int limitCount) {
}

public static Label createLabel(Long labelId, String imageUrl, int limitCount, int ownedCount) {
validateCount(limitCount);
validateCount(ownedCount);
return new Label(labelId, imageUrl, limitCount, ownedCount);
}

public static Label createLabel(String imageUrl, int limitCount) {
validateCount(limitCount);
return new Label(imageUrl, limitCount);
}

private static void validateCount(int count) {
if (count < 0) {
throw new InvalidLabelException("라벨 인원수는 음수일 수 없습니다.");
}
}

public LabelResponseDTO toLabelResponseDTO() {
return new LabelResponseDTO(this.labelId, this.imageUrl);
}
Expand Down

0 comments on commit 4146da5

Please sign in to comment.