Deklarierung von Constraints bei DTOs
This commit is contained in:
1 parent
292c1922dd
commit
f108692809
6 files changed
+36
-5
No files matched your search
@@ -1,4 +1,6 @@
|
||||
package de.timaldinger.einkaufsliste.Dto.Patch;
|
||||
|
||||
public record ShoppingCategoryPatchDTO(String categoryName) {
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
public record ShoppingCategoryPatchDTO(@NotBlank(message = "categoryName can't be blank") String categoryName) {
|
||||
}
|
||||
@@ -1,6 +1,15 @@
|
||||
package de.timaldinger.einkaufsliste.Dto.Patch;
|
||||
|
||||
import jakarta.validation.constraints.AssertTrue;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public record ShoppingItemPatchDTO(String itemName, String itemAmount, Boolean isDone, UUID categoryID) {
|
||||
|
||||
@AssertTrue(message = "itemName and itemAmount cant be blank!")
|
||||
private boolean isAtleastOneNotBlank(){
|
||||
boolean n = itemName != null && !itemName.isBlank();
|
||||
boolean a = itemAmount != null && !itemAmount.isBlank();
|
||||
return n || a;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
package de.timaldinger.einkaufsliste.Dto.Patch;
|
||||
|
||||
public record ShoppingListPatchDTO(String newListName) {
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
public record ShoppingListPatchDTO(@NotBlank(message = "listName must not be blank!") String newListName) {
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package de.timaldinger.einkaufsliste.Dto.Post;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public record ShoppingCategoryPostDTO(String categoryName, UUID listID) {
|
||||
public record ShoppingCategoryPostDTO(@NotBlank String categoryName, UUID listID) {
|
||||
}
|
||||
@@ -1,6 +1,20 @@
|
||||
package de.timaldinger.einkaufsliste.Dto.Post;
|
||||
|
||||
import jakarta.validation.constraints.AssertTrue;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public record ShoppingItemPostDTO(String itemName, String itemAmount, UUID categoryID, UUID listID){
|
||||
public record ShoppingItemPostDTO(String itemName,
|
||||
String itemAmount,
|
||||
UUID categoryID,
|
||||
@NotNull(message = "listID must not be empty!")
|
||||
UUID listID){
|
||||
|
||||
@AssertTrue(message = "itemName and itemAmount cant be blank!")
|
||||
private boolean atleastOneNotBlank(){
|
||||
boolean n = itemName != null && !itemName.isBlank();
|
||||
boolean a = itemAmount != null && !itemAmount.isBlank();
|
||||
return n || a;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
package de.timaldinger.einkaufsliste.Dto.Post;
|
||||
|
||||
public record ShoppingListPostDTO(String listName) {
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
public record ShoppingListPostDTO(@NotBlank(message = "listName must not be blank!") String listName) {
|
||||
}
|
||||
Reference in new issue
Block a user