[SPRING] @NotNull, @NotEmpty, @NotBlank 차이점

박진서·2023년 6월 1일
0

Spring

목록 보기
4/13

API에서 값을 입력받을 때 validation 체크를 위해 사용되는 어노테이션들이다. 차이점에 대해 알아보자.

@NotNull

  • The annotated element must not be null. Accepts any type.
  • null값만 허용하지 않는다. "", " " 허용한다.

@NotEmpty

  • The annotatd element must not be null nor empty.
    Supported types are
  • null, "" 허용하지 않는다. " "은 허용한다.

@NotBlank

  • The annotated element must not be null and must contain at least one non-whitespace character. Accepts CharSequence.
  • null, "", " " 모두 허용하지 않는다.
profile
백엔드 개발자

0개의 댓글