Skip to content

Commit

Permalink
Member 정규표현식 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
unanchoi committed Apr 29, 2024
1 parent 67f773a commit c9bebad
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.springframework.util.Assert;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;

import static jakarta.persistence.GenerationType.*;

Expand All @@ -19,9 +19,10 @@
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Member extends BaseTimeEntity {

private final static int MAX_AGE = 100;
private final static int MAX_LENGTH = 12;
private final static short CURRENT_GENERATION = 34;
private static final int MAX_AGE = 100;
private static final int MAX_LENGTH = 12;
private static final short CURRENT_GENERATION = 34;
private static final Pattern NAME_PATTERN = Pattern.compile("가-힣");

@Id
@GeneratedValue(strategy = IDENTITY)
Expand Down Expand Up @@ -60,9 +61,10 @@ private void validateAge(final int age) {

// SOPT는 한국인만 가입 가능함.
private void validateName(final String name) {
// if (!name.matches("ㅎ가-힣")) {
// throw new MemberException("한글만 가능합니다.");
// }
if (NAME_PATTERN.matcher(name).matches()) {
throw new MemberException("유저의 이름은 한글만 가능합니다.");
}

if (name.length() > MAX_LENGTH) {
throw new MemberException("유저의 이름은 12자를 넘을 수 없습니다.");
}
Expand Down

0 comments on commit c9bebad

Please sign in to comment.