File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
src/main/java/com/amigoscode/product Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ public UUID saveProduct(@RequestBody @Valid NewProductRequest product) {
3939
4040 @ PutMapping ("{id}" )
4141 public void updateProduct (@ PathVariable UUID id ,
42- @ RequestBody UpdateProductRequest request ) {
42+ @ RequestBody @ Valid UpdateProductRequest request ) {
4343 productService .updateProduct (id , request );
4444 }
4545}
Original file line number Diff line number Diff line change 11package com .amigoscode .product ;
22
3+ import jakarta .validation .constraints .DecimalMin ;
4+ import jakarta .validation .constraints .Min ;
5+ import jakarta .validation .constraints .NotBlank ;
6+ import jakarta .validation .constraints .Size ;
7+
38import java .math .BigDecimal ;
49
510public record UpdateProductRequest (
11+ @ Size (
12+ min = 2 ,
13+ max = 50 ,
14+ message = "Name must be between 2 and 50 characters"
15+ )
616 String name ,
17+
18+ @ Size (
19+ min = 5 ,
20+ max = 500 ,
21+ message = "Description must be between 5 and 500 characters"
22+ )
723 String description ,
24+
825 String imageUrl ,
26+
27+ @ DecimalMin (value = "0.1" , message = "Price must be greater than 0.1" )
928 BigDecimal price ,
29+
30+ @ Min (value = 1 , message = "Min Stock Level is 1" )
1031 Integer stockLevel
1132) {
1233}
You can’t perform that action at this time.
0 commit comments