Demo: writing a custom @ValidSku constraint
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
- Define the SKU format (for example three letters, a dash, four digits:
ABC-1234). - Write the
@ValidSkuannotation andSkuValidator. - Put
@ValidSkuonCreateProductRequest.sku. - Planned mistake: forget
@Validon the controller parameter; a bad SKU gets through. Fix: add@Valid. - 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.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.