이제 회원가입 시
간단한 유효성 검사를 해보자!
@Valid를 사용하여
검사를 해보자
의존성 추가
implementation 'org.springframework.boot:spring-boot-starter-validation'
여기를 보면 기능들이 잘 나와있다
https://bamdule.tistory.com/35
[Spring Boot] @Valid 어노테이션으로 Parameter 검증하기
java.validation의 @Valid 어노테이션 사용법 정리 글입니다. Spring Boot 라이브러리에서 기본적으로 탑재된 기능이며 따로 dependency해 줄 필요가 없습니다. Spring Boot Version은 2.2.2.RELEASE 입니다. 1. j..
bamdule.tistory.com
dto


코딩하면서 제일 무서운 게
null이다 ㅋㅋㅋ
테스트
휴대폰 인증만 하고
이상태에서 회원가입을 누르면


유효성 검사를 통과하지 못하고
저렇게 빈칸 일수 없습니다
4~10 자리여야 합니다 등
메시지를 띄어준다
일부만 채워보면

역시 양을 줄었지만
해당 객체의 경고가 뜬다

정상적으로 제출하면


인서트 완료!
이렇게 간단한
유효성 검사를 만들었다
이제 유효성 검사 실패 시
나오는 메시지를
프런트엔드에게 던져보자!
'Spring boot kim's Shop > 회원가입' 카테고리의 다른 글
Springboot Jwt+회원가입 하기!(2) with RestControllerAdvice/ExceptionHandler (0) | 2021.07.27 |
---|---|
Spring boot jwt+회원가입하기!(1) with insert DB (0) | 2021.07.26 |
Springboot 집주소검색! with 카카오 주소검색 api (0) | 2021.07.24 |
Springboot Jwt+아이디 중복 검사! with XMLHttpRequest (0) | 2021.07.24 |