التحقق عند الحافة
في هذا الدرس 4 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
reject bad input before it reaches the service.
الموضوعات المخطط لها
- Never trust input: clients, scripts, and attackers send anything.
- Validate at the controller boundary, on the request DTO.
- Jakarta Bean Validation: put constraint annotations on fields; add
@Validon the controller parameter. - Frontend checks are for convenience only; the server must check again.
تفاصيل المخطط المبدئي
عرض عملي
record CreateProductRequest(@NotBlank String name, @Positive BigDecimal price) {}
@PostMapping
ProductResponse create(@Valid @RequestBody CreateProductRequest req) { ... }اختبر فهمك
Is frontend validation enough?
أظهر الإجابة
No; anyone can call the API directly.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.