Input validation vs business rules
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
put each kind of rule in the right place.
Planned topics
- Input validation: shape and range of data, checkable from the request alone (not blank, positive, format).
- Business rules: depend on state or domain knowledge (stock is sufficient, SKU is unique, order is not shipped).
- Input rules go on the DTO at the edge; business rules go in the service or domain.
- Create and update often need different rules: use separate DTOs (or validation groups).
Draft outline details
Demonstration
table: "price > 0" input; "SKU not already used" business; "cannot cancel a shipped order" business.
Check your understanding
Where does "SKU must be unique" go?
Show answer
In the service: it needs stored data.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.