I have a very simple Spring Boot application that uses Spring-Data-Mongodb
All I want to do is set a JSR-303 validation rule that says the object I\'m saving must ha
I found that if I add
public User addUser(@RequestBody @Valid User newUser,
BindingResult bindingResult) throws Exception {
if (bindingResult.hasErrors()) {
throw new Exception("Validation Error");
}
To my controller this validates the incoming json against my rules, though I should still try and setup the validatingMongoEventListener to intercept any other parts of my code that attempt to update the model with invalid data.