Module 11 Β· Bookings β Lesson 3 of 3 Β· ~11 min
Business rules
Decoding isn't validating
Decode proves the JSON parsed. It says nothing about whether the booking makes sense. Three rules stand between a decoded request and a real booking:
- Known duration β PawWalk sells 30, 45, 60. A request for 37 minutes is nonsense; reject it.
- Not in the past β you can't book a walk for yesterday.
- No double-booking β a walker can't be in two places at once, so their slot must be free.
Each rule that fails is a specific kind of wrong, and the app deserves to be told which. That's what domain errors are for.