Practice ยท 1 of 3
Guard Clauses that Accumulate
CHALLENGE
Difficulty: intermediate+25 XP
Implement Validate with guard clauses. Unlike fail-fast validation, this one **accumulates every violation in a fixed order**:
1. order itself null โ "order"
2. Customer null/empty โ "customer"
3. no items โ "items"
4. each negative-qty item, in order โ "qty:" + index (0-based)
Valid input โ an empty list. Guard clauses keep each rule on one line; the
rules still *all* run (except when a earlier rule makes a later one
meaningless โ null order has no items to inspect).
``csharp
public static class Solution { public static System.Collections.Generic.List<string> Validate(Solution.Order? order); }
``
Press Submit to check your solution.
Back to lesson: Practice: Clean Code Practice: Guards, Totals, Reports