Skip to content

Commit

Permalink
Merge pull request #204 from ITZipProject/feature/user-nickname-regul…
Browse files Browse the repository at this point in the history
…ar-expression

✨ 새 기능 : 닉네임 정규식 구현
  • Loading branch information
rowing0328 authored Jan 8, 2025
2 parents fd56771 + 4861ed0 commit 9ee9a61
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
Expand All @@ -40,7 +40,14 @@ public class MypageController {
@ResponseCodeAnnotation(CommonResponseCode.SUCCESS)
@ExceptionCodeAnnotations({CommonExceptionCode.FILED_ERROR})
public String checkDuplicateNickname(
@Parameter(description = "사용할 닉네임") @RequestParam @NotBlank String nickname
@Parameter(description = "사용할 닉네임")
@RequestParam
@NotBlank
@Pattern(
regexp = "^(?=.*[가-힣a-zA-Z])[가-힣a-zA-Z0-9 _-]{2,16}$",
message = "올바르지 않은 닉네임 형식입니다."
)
String nickname
) {
return mypageService.checkDuplicateNickname(nickname);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.Pattern;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand All @@ -14,6 +15,8 @@
@AllArgsConstructor
public class ChangeNicknameRequest {
@NotEmpty(message = "닉네임을 입력해주세요.")
@Pattern(regexp = "^(?=.*[가-힣a-zA-Z])[가-힣a-zA-Z0-9 _-]{2,16}$",
message = "올바르지 않은 닉네임 형식입니다.")
@Schema(description = "닉네임", example = "뛰어난 1번째 사자")
private String nickname;
}

0 comments on commit 9ee9a61

Please sign in to comment.