Skip to content
Ameen Abozaid
Planned lessonJNR-014-L06

Demo: writing a custom @ValidSku constraint

  • Lesson 6 of 6
  • Junior
On This Lesson 3 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

add @ValidSku to product creation; prepares JNR-014-LAB1.

Draft outline details

Step by step

  1. Define the SKU format (for example three letters, a dash, four digits: ABC-1234).
  2. Write the @ValidSku annotation and SkuValidator.
  3. Put @ValidSku on CreateProductRequest.sku.
  4. Planned mistake: forget @Valid on the controller parameter; a bad SKU gets through. Fix: add @Valid.
  5. Post a bad SKU and see a 400; post a good one and see success.

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Type to search levels, phases, modules and lessons.