Command Objects Code Assignment
Okay, it's your turn to write some code. Let's apply what we've learned in this module.
- Create a new ProductForm object. This should have id, version, description, price, and image url. Properties should match Product domain class.
- Description cannot be blank, and must be more than 5 characters, but less than 200.
- Price must be a number greater than zero, less than 5000.
- Use HTML 5 to limit input of price as a number.
- Image URL string must be a valid URL.
- Update Product controller to use ProductForm Command object. Should validate, and redirect to form if not valid.
- Update product template to use ProductForm. Add error notice at top. Each field should be display error message information.
- Create user friendly custom error messages for each validation constraint.
- Create a converter for ProductForm to Product and Product to ProductForm.
- Update persistence services to maintain CRUD functionality. Override saveOrUpdate method to accept and return ProductForm.
- Verify all unit tests are passing.
Extra Credit Challenge
On the CustomerForm object, create a custom validator to verify the two password strings match. If they do not, reject both fields & provide notification message to user. Hint: you will not be able to use an annotation for this. You will need to google for the solution. I did not show you how to do this.
Get the Source
The beginning source code for this module is available here on GitHub.