diff options
| author | realtradam <[email protected]> | 2024-07-11 21:08:42 -0400 |
|---|---|---|
| committer | realtradam <[email protected]> | 2024-07-11 21:08:42 -0400 |
| commit | 40075162def7d0a4ce9d795f4cfe83264fac50b4 (patch) | |
| tree | 9048db522f46519ab19554434606897f974db488 /src/main/java/com/blog/web/dto/ArticleDto.java | |
| parent | 86cb044572b9e07d4b63871b9a3f4b384bed4caa (diff) | |
| download | spring-blog-40075162def7d0a4ce9d795f4cfe83264fac50b4.tar.gz spring-blog-40075162def7d0a4ce9d795f4cfe83264fac50b4.zip | |
validate new and edited article fields
Diffstat (limited to 'src/main/java/com/blog/web/dto/ArticleDto.java')
| -rw-r--r-- | src/main/java/com/blog/web/dto/ArticleDto.java | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main/java/com/blog/web/dto/ArticleDto.java b/src/main/java/com/blog/web/dto/ArticleDto.java index ffe7926..0c48f62 100644 --- a/src/main/java/com/blog/web/dto/ArticleDto.java +++ b/src/main/java/com/blog/web/dto/ArticleDto.java @@ -3,10 +3,12 @@ package com.blog.web.dto; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; +import jakarta.validation.constraints.NotEmpty; import lombok.Builder; import lombok.Data; import org.hibernate.annotations.CreationTimestamp; import org.hibernate.annotations.UpdateTimestamp; +import org.hibernate.validator.constraints.URL; import java.time.LocalDateTime; @@ -16,12 +18,15 @@ public class ArticleDto { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; + @NotEmpty(message = "Article title should not be empty") private String title; + @NotEmpty(message = "Article Photo URL should not be empty") + @URL(message = "Article Photo URL should be a URL") private String photoUrl; + @NotEmpty(message = "Article Content should not be empty") private String content; @CreationTimestamp private LocalDateTime createdOn; @UpdateTimestamp private LocalDateTime updatedOn; - } |
