Skip to main content

Validation Pipeline

Challenge on lesson: Checkpoint: Error Architecture

Build Solution: - static class ValidationException extends RuntimeException carrying List<String> errors (getter errors()); message joins the errors. - static void validate(List<String> fields): collect ALL failures — blank fields (null or isBlank) become error "field " + index + " blank"; then throw ValidationException with the full error list if any. - static int firstError(RuntimeException e): returns 0 when e is a ValidationException, -1 otherwise. Fail-fast would have stopped at the first problem — you collect everything, which is what a validation *pipeline* means.

Difficulty: intermediate

Back to lesson: Checkpoint: Error Architecture