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 prefix
To customize the spring data-rest configuration, register a RepositoryRestConfigurer
(or extend RepositoryRestConfigurerAdapter
) and implement or override the configureValidatingRepositoryEventListener
method for your specific use case.
public class CustomRepositoryRestConfigurer extends RepositoryRestConfigurerAdapter {
@Autowired
private Validator validator;
@Override
public void configureValidatingRepositoryEventListener(ValidatingRepositoryEventListener validatingListener) {
validatingListener.addValidator("beforeCreate", validator);
validatingListener.addValidator("beforeSave", validator);
}
}