Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- db
- java
- QueryDSL
- Exception
- 자바
- 스프링 핵심 원리
- Greedy
- http
- Android
- JPQL
- 알고리즘
- jpa
- Proxy
- Servlet
- transaction
- pointcut
- 스프링 핵심 기능
- SpringBoot
- spring
- Spring Boot
- 인프런
- springdatajpa
- 스프링
- AOP
- JDBC
- 김영한
- kotlin
- Thymeleaf
- 그리디
- 백준
Archives
- Today
- Total
개발자되기 프로젝트
Bean Validation 본문
검증 기능을 지금처럼 매번 코드로 작성하는 것은 귀찮음...
특히 특정 필드에 대한 검증 로직은 대부분 빈 값인지 아닌지, 특정 크기를 넘는지 아닌지와 같이 매우 일반적 로직임.
??? : 그러면 @Annotation으로 처리해보자.
public class Item {
private Long id;
@NotBlank
private String itemName;
@NotNull
@Range(min = 1000, max = 1000000)
private Integer price;
@NotNull
@Max(9999)
private Integer quantity;
//...
}
1. Bean Validation
- 먼저 Bean Validation은 특정한 구현체가 아니라 Bean Validation 2.0(JSR-380)이라는 기술 표준
(검증 애노테이션과 여러 인터페이스의 모음이다.) - 마치 JPA가 표준 기술이고 그 구현체로 하이버네이트가 있는 것과 같다.
- Bean Validation을 구현한 기술중에 일반적으로 사용하는 구현체는 하이버네이트 Validator.
(ORM과는 관련이 없다.) - 공식 사이트: http://hibernate.org/validator/
- 공식 메뉴얼: https://docs.jboss.org/hibernate/validator/6.2/reference/en-US/html_single/
- 검증 애노테이션 모음: https://docs.jboss.org/hibernate/validator/6.2/reference/en-US/ html_single/#validator-defineconstraints-spec
'인프런 > [인프런] 스프링 MVC 2' 카테고리의 다른 글
Bean Validation - Spring 적용 (0) | 2021.09.25 |
---|---|
Bean Validation - 시작 (0) | 2021.09.25 |
Validator 분리 2 (0) | 2021.09.24 |
Validator 분리 1 (0) | 2021.09.24 |
오류코드와 메시지 처리6 (0) | 2021.09.24 |
Comments