When going over the chaper where validation is set, you also add an argument Error error to your controller methods. Pay attention that error is immediately following your @Valid argument as in the example below. I placed it at first at the end of my args and kept receiving the Whitelable error.
Explanation: Spring matches the injected Errors arg with the preceding @Valid object. If the Errors arg isn’t directly after the @Valid arg, Spring won’t know which object the validation results belong to.
@PostMapping
public String processTaco(**@Valid Taco taco, Errors errors,** @ModelAttribute TacoOrder tacoOrder) {
if(errors.hasErrors()) {
return "design";
}
tacoOrder.addTaco(taco);
log.info("Processing taco: {}", taco);
return "redirect:/orders/current";
}