use of com.haulmont.cuba.gui.components.CompositeValidationException in project cuba by cuba-platform.
the class BeanValidator method validate.
@Override
public void validate(Object value) throws ValidationException {
BeanValidation beanValidation = AppBeans.get(BeanValidation.NAME);
Validator validator = beanValidation.getValidator();
Class[] groups = this.validationGroups;
if (groups == null || groups.length == 0) {
groups = new Class[] { Default.class, UiComponentChecks.class };
}
@SuppressWarnings("unchecked") Set<ConstraintViolation> violations = validator.validateValue(beanClass, beanProperty, value, groups);
if (!violations.isEmpty()) {
List<CompositeValidationException.ViolationCause> causes = new ArrayList<>();
for (ConstraintViolation violation : violations) {
causes.add(new BeanValidationViolationCause(violation));
}
String validationMessage = this.validationErrorMessage;
if (validationMessage == null) {
validationMessage = getDefaultErrorMessage();
}
throw new CompositeValidationException(validationMessage, causes);
}
}
Aggregations