diff --git a/README.md b/README.md index 789090c3e..2980bfa52 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,5 @@ ## 1단계 요구사항 - 유효성 검사 및 예외 처리 - 상품을 추가하거나 수정할 때 -- [] 공백을 포함하여 최대 15자까지 입력하였는지 유효성을 검증한다. -- [] 가능한 특수문자(( ), [ ], +, -, &, /, _)를 사용하였는지 검증한다. - +- [x] 공백을 포함하여 최대 15자까지 입력하였는지 유효성을 검증한다. +- [x] 가능한 특수문자(( ), [ ], +, -, &, /, _)를 사용하였는지 검증한다. \ No newline at end of file diff --git a/build.gradle b/build.gradle index 575a63230..46ec01c8b 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,13 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-jdbc' implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' implementation 'org.springframework.boot:spring-boot-starter-web' + implementation 'org.springframework.boot:spring-boot-starter-validation' + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' + implementation 'org.springframework.boot:spring-boot-starter-security' runtimeOnly 'com.h2database:h2' + compileOnly 'io.jsonwebtoken:jjwt-api:0.12.6' + runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.12.6' + runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.12.6' testImplementation 'org.springframework.boot:spring-boot-starter-test' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' implementation 'org.springframework.boot:spring-boot-starter-validation' diff --git a/src/main/java/gift/domain/Product.java b/src/main/java/gift/domain/Product.java index cb69bbf5b..f5a0bb09e 100644 --- a/src/main/java/gift/domain/Product.java +++ b/src/main/java/gift/domain/Product.java @@ -9,7 +9,7 @@ public class Product { @NotBlank(message = "Name cannot be blank") @Size(max = 15, message = "Name cannot be longer than 15 characters") - @Pattern(regexp = "^[\\w\\s\\(\\)\\[\\]+\\-&/_]*$", message = "Name contains invalid characters") // 정규표현식을 통한 특수 문자 제어 + @Pattern(regexp = "^[ㄱ-ㅎ가-힣a-zA-Z0-9\\s\\(\\)\\[\\]+\\-&/_]*$", message = "이름에 유효하지 않은 문자가 포함되어 있습니다") private String name; private int price; private String imageUrl;