Skip to content

Commit

Permalink
test: 닉네임에서 이모티콘과 특수문자 검출하는 정규표현식 수정 (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdkdhoho committed Jan 28, 2024
1 parent 7b629d4 commit e419379
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/listywave/user/vo/Nickname.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private void validate(String value) {
if (value.length() >= LENGTH_LIMIT) {
throw new RuntimeException("닉네임은 " + LENGTH_LIMIT + "자를 넘을 수 없습니다.");
}
if (value.matches("[\\x{10000}-\\x{10FFFF}]|[\\p{Punct}]")) {
if (!value.matches("[가-힣a-zA-Z0-9]+")) {
throw new RuntimeException("닉네임에는 이모티콘 및 특수문자가 포함될 수 없습니다.");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/listywave/user/vo/NicknameTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class NicknameTest {
}

@ParameterizedTest
@ValueSource(strings = {"닉네임👍", "닉네임!", "!@#!@$@!$%@$^%$&*(&^*%&^$"})
@ValueSource(strings = {"닉네임👍", "닉네임!", "*(&^*%&^$"})
void 이모티콘_및_특수문자가_포함될_수_없다(String value) {
// expect
assertThatThrownBy(() -> new Nickname(value))
Expand Down

0 comments on commit e419379

Please sign in to comment.