Practical chapter 04 · guided challenge · 4 test cases per challenge
Validation and boundaries
Design rules with explicit outcomes for optional data, zero values, and boundary cases.
01Optional discount codeAllow a missing code, but validate the exact format of a present code.Solve challenge02Safe ratioPrevent division by zero and return the same type from both branches.Solve challenge03One delivery methodRequire a pickup location or a shipping address, but not both.Solve challenge04Half-open rangeInclude the lower boundary and exclude the upper boundary.Solve challenge