Skip to content

Commit 3154018

Browse files
Sihun23Sihun23
authored andcommitted
CLAP-434 fix:닉네임 정규식 검증 에러 핸들링 추가
1 parent 67d971d commit 3154018

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/main/java/clap/server/application/service/admin/CsvParseService.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.nio.charset.Charset;
2121
import java.util.ArrayList;
2222
import java.util.List;
23+
import java.util.regex.Pattern;
2324

2425
import static clap.server.domain.model.member.MemberInfo.toMemberInfo;
2526

@@ -32,6 +33,8 @@ public class CsvParseService {
3233
private final LoadDepartmentPort loadDepartmentPort;
3334
private final ManagerInfoUpdatePolicy managerInfoUpdatePolicy;
3435

36+
private static final Pattern NICKNAME_PATTERN = Pattern.compile("^[a-z]{3,10}\\.[a-z]{1,5}$");
37+
3538
public List<Member> parseDataAndMapToMember(MultipartFile file) {
3639
List<Member> members = new ArrayList<>();
3740
List<Department> departments = loadDepartmentPort.findActiveDepartments();
@@ -56,6 +59,11 @@ public List<Member> parseDataAndMapToMember(MultipartFile file) {
5659
}
5760

5861
private Member mapToMember(String[] fields, List<Department> departments) {
62+
String nickname = fields[1].trim();
63+
64+
if (!NICKNAME_PATTERN.matcher(nickname).matches()) {
65+
throw new ApplicationException(MemberErrorCode.INVALID_NICKNAME_FORMAT);
66+
}
5967

6068
if (!validateEmailAndNickname(fields[4].trim(), fields[1].trim())) {
6169
throw new ApplicationException(MemberErrorCode.INVALID_EMAIL_NICKNAME_MATCH);

src/main/java/clap/server/exception/code/MemberErrorCode.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public enum MemberErrorCode implements BaseErrorCode {
2121
MANAGER_PERMISSION_DENIED(HttpStatus.BAD_REQUEST, "MEMBER_013", "담당자 권한이 없는 부서입니다."),
2222
INVALID_EMAIL_NICKNAME_MATCH(HttpStatus.BAD_REQUEST, "MEMBER_014", "닉네임과 이메일이 일치하지 않습니다"),
2323
MANAGER_MEMBER_UPDATE_NOT_ALLOWED_WITH_TASKS(HttpStatus.BAD_REQUEST, "MEMBER_015", "잔여 작업이 남아있어 수정이 불가합니다."),
24+
INVALID_NICKNAME_FORMAT(HttpStatus.BAD_REQUEST, "MEMBER_016", "잘못된 닉네임 형식입니다."),
25+
2426
;
2527

2628
private final HttpStatus httpStatus;

0 commit comments

Comments
 (0)