I understand from the docs http://docs.spring.io/spring-data/rest/docs/2.1.2.RELEASE/reference/html/validation-chapter.html that I can declare validators with certain prefixes.
I'm using JSR 303 so my domain entities are annotated with validation annotations.
Can - and if yes, how - I use JSR 303 Bean Validation with Spring Data Rest?
PS: I'm using Spring Boot
This seems to work:
@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);
}
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments