Skip to content
Snippets Groups Projects
Commit 742ab9c7 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-4949 Changed Validator registration

parent 209a52e8
No related branches found
No related tags found
No related merge requests found
package de.ozgcloud.admin.settings;
import java.util.Map;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.rest.core.event.ValidatingRepositoryEventListener;
import org.springframework.validation.Validator;
import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer;
@Configuration
public class ValidatorEventRegister implements InitializingBean {
@Autowired
ValidatingRepositoryEventListener validatingRepositoryEventListener;
public class DataRestConfiguration implements RepositoryRestConfigurer {
@Autowired
private Map<String, Validator> validators;
private SettingsValidator settingsValidator;
@Override
public void afterPropertiesSet() throws Exception {
validatingRepositoryEventListener.addValidator("beforeSave", validators.get("settingsValidator"));
validatingRepositoryEventListener.addValidator("beforeCreate", validators.get("settingsValidator"));
public void configureValidatingRepositoryEventListener(ValidatingRepositoryEventListener v) {
v.addValidator("beforeSave", settingsValidator);
v.addValidator("beforeCreate", settingsValidator);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment