Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@

## 1단계 요구사항 - 유효성 검사 및 예외 처리
- 상품을 추가하거나 수정할 때
- [] 공백을 포함하여 최대 15자까지 입력하였는지 유효성을 검증한다.
- [] 가능한 특수문자(( ), [ ], +, -, &, /, _)를 사용하였는지 검증한다.

- [x] 공백을 포함하여 최대 15자까지 입력하였는지 유효성을 검증한다.
- [x] 가능한 특수문자(( ), [ ], +, -, &, /, _)를 사용하였는지 검증한다.
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/gift/domain/Product.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down