0

My springboot version is 2.3.7. I know that spring-boot-starter-validation is not a transitive dependency of spring-boot-starter-web. But even after adding it separately my annotations are not working.

//below dependency i have added in build.gradle compile 'org.springframework.boot:spring-boot-starter-validation'

//sample class for which I want error when requested

 @Data
    @JsonIgnoreProperties(ignoreUnknown = true)
    @NoArgsConstructor
    @RequiredArgsConstructor(staticName = "of")
    public class UpdateRequest {
    
        @NotNull
        @NonNull
        private BigDecimal number;
    }

Here, lombok @NonNull is working but @NotNull is not. Nor other javax validators. What else is I am missing here?

maverickabhi
  • 197
  • 1
  • 6
  • 21

1 Answers1

0

I suspect you are missing @Valid on the UpdateRequest parameter of your request handler method:


@PostMapping("somepath")
public String update(@Valid UpdateRequest updateRequest, BindingResult bindingResult)


Jeff
  • 3,712
  • 2
  • 22
  • 24