Open spring-projects-issues opened 10 years ago
Marcel Overdijk opened DATAREST-372 and commented
The Spring Data REST homepage states:
However in the documentation I cannot find back how this should be enabled. By default entities with JSR-303 annotation are not validated.
What I did to make it working is:
@Configuration protected static class CustomRepositoryRestMvcConfiguration extends RepositoryRestMvcConfiguration { @Autowired private Validator validator; @Override protected void configureValidatingRepositoryEventListener(ValidatingRepositoryEventListener validatingListener) { validatingListener.addValidator("beforeCreate", validator); validatingListener.addValidator("beforeSave", validator); } }
I don't know if this the best way to enable JSR-303 bean validation but either way I think it's good to add to the documentation how to enable it
Affects: 2.1.2 (Dijkstra SR2)
6 votes, 8 watchers
Marcel Overdijk commented
See also discussion: http://stackoverflow.com/questions/25220440/can-jsr-303-bean-validation-be-used-with-spring-data-rest
Marcel Overdijk opened DATAREST-372 and commented
The Spring Data REST homepage states:
However in the documentation I cannot find back how this should be enabled. By default entities with JSR-303 annotation are not validated.
What I did to make it working is:
I don't know if this the best way to enable JSR-303 bean validation but either way I think it's good to add to the documentation how to enable it
Affects: 2.1.2 (Dijkstra SR2)
6 votes, 8 watchers