๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Spring

Bean Validation (Hibernate Validation)

by ์ฃผ๋ฐœ2 2023. 9. 30.
๋ฐ˜์‘ํ˜•

Bean Validation์€ ํ•„๋“œ์˜ ๊ฐ’, ๋ฒ”์œ„ ๋“ฑ์„ ๊ฒ€์ฆํ•˜๊ณ ์ž ํ•  ๋•Œ ์œ ์šฉํ•˜๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ์–ด๋…ธํ…Œ์ด์…˜ ๋ฐ ์ธํ„ฐํŽ˜์ด์Šค์˜ ๋ชจ์Œ

์ด ๊ธฐ์ˆ ์˜ ๊ตฌํ˜„์ฒด ์ค‘ ์ผ๋ฐ˜์ ์œผ๋กœ ์‚ฌ์šฉํ•˜๋Š” ๊ตฌํ˜„์ฒด๊ฐ€ Hibernate Validator 

 

 

https://docs.jboss.org/hibernate/validator/6.2/reference/en-US/html_single/#validator-defineconstraints-spec

 

Hibernate Validator 6.2.5.Final - Jakarta Bean Validation Reference Implementation: Reference Guide

Validating data is a common task that occurs throughout all application layers, from the presentation to the persistence layer. Often the same validation logic is implemented in each layer which is time consuming and error-prone. To avoid duplication of th

docs.jboss.org

 

@NotBlank, @NotEmpty, @Min, @Max ๋“ฑ ์ผ๋ถ€ ์–ด๋…ธํ…Œ์ด์…˜์€ ์ข…์ข… ์‚ฌ์šฉํ–ˆ์—ˆ๋Š”๋ฐ, ๋ฌธ์„œ๋ฅผ ํ™•์ธํ•ด๋ณด๋‹ˆ ๊ต‰์žฅํžˆ ๋งŽ์€ ์–ด๋…ธํ…Œ์ด์…˜์ด ์กด์žฌํ•˜๊ณ  ์žˆ๋‹ค. 

 

@NotNull vs @NotEmpty vs @NotBlank

 

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€