Skip to content

Commit cd81149

Browse files
authored
Merge pull request #338 from RealMatchTeam/fix/337-dupnick
[FIX] 닉네임 중복로직 해결
2 parents aeafcbe + 16d419b commit cd81149

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

src/main/java/com/example/RealMatch/user/application/service/UserService.java

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -129,21 +129,8 @@ public void updateMyInfo(Long userId, MyEditInfoRequestDto request) {
129129
User user = userRepository.findById(userId)
130130
.orElseThrow(() -> new CustomException(UserErrorCode.USER_NOT_FOUND));
131131

132-
// 닉네임 중복 체크
133-
if (userRepository.existsByNickname(request.nickname()) &&
134-
!user.getNickname().equals(request.nickname())) {
135-
throw new CustomException(UserErrorCode.DUPLICATE_NICKNAME);
136-
}
137-
138-
// 닉네임 형식 체크 (한글, 영문, 숫자만)
139-
if (!request.nickname().matches("^[가-힣a-zA-Z0-9]+$")) {
140-
throw new CustomException(UserErrorCode.INVALID_NICKNAME_FORMAT);
141-
}
142-
143-
// 닉네임 길이 체크 (2~10자)
144-
if (request.nickname().length() < 2 || request.nickname().length() > 10) {
145-
throw new CustomException(UserErrorCode.INVALID_NICKNAME_LENGTH);
146-
}
132+
// NicknameValidator의 validateForUpdate 사용
133+
nicknameValidator.validateForUpdate(request.nickname(), user.getNickname());
147134

148135
// 정보 수정
149136
user.updateInfo(

0 commit comments

Comments
 (0)