Free practice · ordering · medium

Practice

Order an input-validation pipeline

Arrange a safe pipeline for a required whole-number quantity received as text.

Trusted input boundary

Business logic receives only validated, typed values

  1. PresenceRequired value supplied
  2. FormatAllowed external form
  3. ConvertFocused typed conversion
  4. RangeAllowed business limits
  5. UsePass checked value to logic
  6. ReportReturn useful safe failures

Presence, type, format, conversion, and range checks belong at a narrow boundary with useful failures and no hidden fallback.

Arrange in the correct order
  1. 1. Use the validated integer in business logic
  2. 2. Confirm the integer is within the allowed range
  3. 3. Convert the checked text to int
  4. 4. Confirm the text represents an allowed whole-number form
  5. 5. Check that required input is present