Spring/Spring MVC
Spring MVC - JSR-380 어노테이션(Annotation)
jddng
2022. 1. 3. 15:25
728x90
반응형
JSR-380 어노테이션(Annotation)
- JSR-303와 원리는 같고 유효성 검사가 추가로 제공
더보기
https://beanvalidation.org/2.0-jsr380/spec/
Bean Validation specification
BeanNode, PropertyNode and ContainerElementNode host getContainerClass() and getTypeArgumentIndex(). If the node represents an element that is contained in a container such as Optional, List or Map, the former returns the declared type of the container and
beanvalidation.org
더보기
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.0.7.Final</version>
</dependency>
유효성 검사 어노테이션
많이 쓰는 어노테이션만 작성하였다. 다른 필요한 어노테이션이 있다면 위 참고 링크를 참고해라.
어노테이션(Annotation) | 내용 |
@NotEmpty | 주입된 값의 길이가 0이면 오류, 공백도 글자로 인식한다. |
@NotBlank | 주입된 값이 길이가 0이면 오류, 공백은 글자로 인식안한다. |
@Positive | 양수가 아니면 오류 - 값을 주입할때 String으로 주입하면 오류난다 |
@PositiveOrZero | 0 또는 양수가 아니면 오류 - 값을 주입할때 String으로 주입하면 오류난다 |
@Negative | 음수가 아니면 오류 - 값을 주입할때 String으로 주입하면 오류난다 |
@NegativeOrZero | 0 또는 음수가 아니면 오류 - 값을 주입할때 String으로 주입하면 오류난다 |
이메일 형식이 아니라면 오류, 중간에 @가 있는지 확인 |
728x90
반응형