Skip to content

Commit

Permalink
Add nickname-length exception-handling logic (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
jinlee1703 authored Oct 23, 2023
2 parents 82ecbe8 + e067803 commit 00d3b92
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;

import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
public class UserUpdateRequestDto {
private String nickname;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ public UserUpdateResponseDto update(String username, Long userId, UserUpdateRequ
if (!user.getId().equals(userId)) {
throw new BusinessException("수정 권한이 없습니다.", StatusEnum.FORBIDDEN);
}
if (userUpdateRequestDto.getNickname().length() < 2 || userUpdateRequestDto.getNickname().length() > 12) {
throw new BusinessException("닉네임은 2자 이상 12자 이하로 입력해주세요.", StatusEnum.BAD_REQUEST);
}
if (userUpdateRequestDto.getNickname() != null) {
if (isDuplicateNickname(userUpdateRequestDto.getNickname())) {
throw new BusinessException("이미 존재하는 닉네임입니다.", StatusEnum.CONFLICT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@AllArgsConstructor
public enum Role {
ADMIN("ROLE_ADMIN,ROLE_USER,ROLE_TEMPORARY"),
USER("ROLE_USER,ROLE_TEMPORARY"),
USER("ROLE_USER,ROLE_ANONYMOUS"),
ANONYMOUS("ROLE_ANONYMOUS");

private String value;
Expand Down

0 comments on commit 00d3b92

Please sign in to comment.