From 06d40d5ba0511a1ff2fe690127751345f2021e81 Mon Sep 17 00:00:00 2001 From: Amodu Date: Tue, 27 Aug 2024 20:43:18 +0100 Subject: [PATCH] Refactor: Added validation --- .../product/dto/ProductDTO.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/hng_java_boilerplate/product/dto/ProductDTO.java b/src/main/java/hng_java_boilerplate/product/dto/ProductDTO.java index 0b1af0dc..a54a7100 100644 --- a/src/main/java/hng_java_boilerplate/product/dto/ProductDTO.java +++ b/src/main/java/hng_java_boilerplate/product/dto/ProductDTO.java @@ -1,5 +1,7 @@ package hng_java_boilerplate.product.dto; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -13,12 +15,28 @@ @NoArgsConstructor @AllArgsConstructor public class ProductDTO { + private String id; + @NotNull(message = "Name is required") + @NotBlank(message = "Name is required") private String name; + + @NotNull(message = "Name is required") + @NotBlank(message = "Name is required") private String description; + + @NotNull(message = "Name is required") + @NotBlank(message = "Name is required") private String category; + + @NotNull(message = "Name is required") + @NotBlank(message = "Name is required") private Double price; + + @NotNull(message = "Name is required") + @NotBlank(message = "Name is required") private String image_url; + private LocalDateTime created_at; private LocalDateTime updated_at; }