2018-06-27 12:29:21 +02:00
|
|
|
package eu.eudat.models.validators;
|
2018-01-03 17:36:31 +01:00
|
|
|
|
2018-06-27 12:29:21 +02:00
|
|
|
import eu.eudat.models.data.admin.composite.DatasetProfile;
|
2018-01-03 17:36:31 +01:00
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import org.springframework.validation.Errors;
|
|
|
|
import org.springframework.validation.Validator;
|
|
|
|
|
2018-02-01 10:08:06 +01:00
|
|
|
|
2018-01-03 17:36:31 +01:00
|
|
|
@Component("datasetProfileValidator")
|
|
|
|
public class DatasetProfileValidator implements Validator {
|
|
|
|
@Override
|
|
|
|
public boolean supports(Class<?> aClass) {
|
|
|
|
return DatasetProfile.class.equals(aClass);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void validate(Object obj, Errors errors) {
|
|
|
|
DatasetProfile datasetProfile = (DatasetProfile) obj;
|
2018-02-16 11:34:02 +01:00
|
|
|
if (datasetProfile.getLabel() == null) {
|
2018-01-03 17:36:31 +01:00
|
|
|
errors.rejectValue("label", "datasetprofile.label.null");
|
|
|
|
}
|
|
|
|
}
|
2018-02-16 11:34:02 +01:00
|
|
|
|
2018-01-03 17:36:31 +01:00
|
|
|
public static boolean supportsType(Class<?> clazz) {
|
|
|
|
return DatasetProfile.class.equals(clazz);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|