springboot validation 检验模式

时间:2025-03-11 07:44:11

springboot validation 检验模式

 

默认:对pojo的所有参数进行检验,如果检验出错,返回所有错误

fail-fast:检验到参数出错就返回当前错误,不需要检验所有的参数

 

 

*************************

示例

 

*******************

pojo 层

 

Order

@Data
public class Order {

    @FutureOrPresent(message = "时间不能为过去时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime