package com.google.sitebricks.validation;

import java.util.List;
import java.util.Set;

import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import javax.validation.ValidationException;

import com.google.common.collect.Lists;

public class ValidationUtil {
    
    public static List<String> toErrors(ValidationException ve) {
        ConstraintViolationException cve = (ConstraintViolationException) ve.getCause();
        return toErrors((Set<? extends ConstraintViolation<Object>>) cve.getConstraintViolations());
    }
    
    public static List<String> toErrors(Set<? extends ConstraintViolation<Object>> cvs) {
        List<String> errors = Lists.newArrayList();
        for (ConstraintViolation<?> cv: cvs) {
            errors.add(cv.getMessage());
        }
        return errors;
    }
    
}

@@ -517,22 +517,17 @@
 olation%3C
-Object
+?
 %3E%3E) cve.
@@ -643,14 +643,9 @@
 ion%3C
-Object
+?
 %3E%3E c

fix for generic cast typesafety