class ConstraintViolationExceptionMapper implements ExceptionMapper<ConstraintViolationException> {

    @Override
    public Response toResponse(final ConstraintViolationException exception) {
        final List<ValidationError> errors = mapToValidationErrors(exception.getConstraintViolations());

        return Response
                .status(Response.Status.BAD_REQUEST)
                .entity(errors)
                .build();
    }

    /**
     * Copied from {@link AlpineResource#contOnValidationError(Set[])}.
     *
     * @param violations A {@link Collection} or one or more {@link ConstraintViolation}s
     * @return A {@link List} of zero or more {@link ValidationError}s
     * @see <a href="https://github.com/stevespringett/Alpine/blob/76f5bfd6b2d9469e8a42ba360b3b3feef7a87a8b/alpine-server/src/main/java/alpine/server/resources/AlpineResource.java#L155-L190">Source</a>
     */
    private static List<ValidationError> mapToValidationErrors(final Collection<ConstraintViolation<?>> violations) {<FILL_FUNCTION_BODY>}

}

        final List<ValidationError> errors = new ArrayList<>(violations.size());

        for (final ConstraintViolation<?> violation : violations) {
            if (violation.getPropertyPath().iterator().next().getName() != null) {
                final String path = violation.getPropertyPath() != null ? violation.getPropertyPath().toString() : null;
                final String message = violation.getMessage() != null ? StringUtils.removeStart(violation.getMessage(), path + ".") : null;
                final String messageTemplate = violation.getMessageTemplate();
                final String invalidValue = violation.getInvalidValue() != null ? violation.getInvalidValue().toString() : null;
                final ValidationError error = new ValidationError(message, messageTemplate, path, invalidValue);
                errors.add(error);
            }
        }

        return errors;
    
<no_super_class>