29 lines
832 B
Java
29 lines
832 B
Java
package eu.eudat.validators;
|
|
|
|
import eu.eudat.models.admin.composite.DatasetProfile;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.validation.Errors;
|
|
import org.springframework.validation.Validator;
|
|
|
|
|
|
@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;
|
|
if (datasetProfile.getLabel() == null) {
|
|
errors.rejectValue("label", "datasetprofile.label.null");
|
|
}
|
|
}
|
|
|
|
public static boolean supportsType(Class<?> clazz) {
|
|
return DatasetProfile.class.equals(clazz);
|
|
}
|
|
|
|
}
|