static void validate(boolean quiet, ColorFormatter colors, CliPrinter printer, ValidatedResult<Model> result) {
        int notes = result.getValidationEvents(Severity.NOTE).size();
        int warnings = result.getValidationEvents(Severity.WARNING).size();
        int errors = result.getValidationEvents(Severity.ERROR).size();
        int dangers = result.getValidationEvents(Severity.DANGER).size();
        int shapeCount = result.getResult().isPresent() ? result.getResult().get().toSet().size() : 0;
        boolean isFailed = errors > 0 || dangers > 0;
        boolean hasEvents = warnings > 0 || notes > 0 || isFailed;

        try (ColorBuffer output = ColorBuffer.of(colors, new StringBuilder())) {
            if (isFailed) {
                output.append(colors.style("FAILURE: ", ColorTheme.ERROR));
            } else {
                output.append(colors.style("SUCCESS: ", ColorTheme.SUCCESS));
            }
            output.append("Validated " + shapeCount).append(" shapes");

            if (hasEvents) {
                output.append(' ').append('(');
                StringJoiner joiner = new StringJoiner(", ");
                if (errors > 0) {
                    appendSummaryCount(joiner, "ERROR", errors);
                }

                if (dangers > 0) {
                    appendSummaryCount(joiner, "DANGER", dangers);
                }

                if (warnings > 0) {
                    appendSummaryCount(joiner, "WARNING", warnings);
                }

                if (notes > 0) {
                    appendSummaryCount(joiner, "NOTE", notes);
                }
                output.append(joiner.toString());
                output.append(')');
            }

            output.append(System.lineSeparator());

            if (!result.getResult().isPresent() || errors + dangers > 0) {
                throw new CliError(output.toString());
            } else if (!quiet) {
                printer.println(output.toString());
            }
        }
    }
Shares logic for validating a model and printing out events.
smithy-cli/src/main/java/software/amazon/smithy/cli/commands/Validator.java