spring-data-rest: `@Valid` is not supported on `@BasePathAwareController`

Bob Tiernay opened DATAREST-593 and commented

@Valid annotations are not respected on @RepositoryRestController annotated controllers as they are with @Controller and @RestController classes. This breaks with convention and expectation of developers.


Affects: 2.3 GA (Fowler)

Issue Links:

  • DATAREST-1266 @BasePathAwareController disables DTO validation (“is duplicated by”)

15 votes, 18 watchers

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 27

Commits related to this issue

Most upvoted comments

Andrea Ratto commented

Basically I think that @Valid should work on @RequestMapping methods, just like normal controllers. That is:

@RequestMapping(value = "/path", method = RequestMethod.POST)
public post(@Valid @RequestBody Enitity entity) {
  doStuff(entity); // this line should not be reached if the entity is not valid.
}