التحقق من المدخلات مقابل قواعد العمل
في هذا الدرس 4 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
put each kind of rule in the right place.
الموضوعات المخطط لها
- 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).
تفاصيل المخطط المبدئي
عرض عملي
table: "price > 0" input; "SKU not already used" business; "cannot cancel a shipped order" business.
اختبر فهمك
Where does "SKU must be unique" go?
أظهر الإجابة
In the service: it needs stored data.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.