From 24c3b7a72c5e9ac12b7e3cbca89b7526e625f324 Mon Sep 17 00:00:00 2001 From: Urban Modig Date: Wed, 8 Oct 2025 19:53:56 +0200 Subject: [PATCH] Validation tightening (DTOs) --- .../se/urmo/hemhub/dto/ProjectTaskDtos.java | 40 +++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/src/main/java/se/urmo/hemhub/dto/ProjectTaskDtos.java b/src/main/java/se/urmo/hemhub/dto/ProjectTaskDtos.java index 64203c1..43a3c26 100644 --- a/src/main/java/se/urmo/hemhub/dto/ProjectTaskDtos.java +++ b/src/main/java/se/urmo/hemhub/dto/ProjectTaskDtos.java @@ -7,9 +7,9 @@ import java.util.*; public class ProjectTaskDtos { // Projects public record CreateProjectRequest( - @NotNull UUID householdId, - @NotBlank String name, - String description + @NotNull(message = "householdId is required") UUID householdId, + @NotBlank(message = "name is required") String name, + @Size(max = 2000, message = "description too long") String description ) {} public record ProjectResponse( @@ -20,30 +20,30 @@ public class ProjectTaskDtos { // Project tasks (existing) public record CreateTaskRequest( - @NotNull UUID projectId, - @NotBlank String title, - String description, - @Pattern(regexp="LOW|MEDIUM|HIGH") String priority, - @Pattern(regexp="OPEN|IN_PROGRESS|DONE") String status, + @NotNull(message = "projectId is required") UUID projectId, + @NotBlank(message = "title is required") String title, + @Size(max = 8000, message = "description too long") String description, + @Pattern(regexp="LOW|MEDIUM|HIGH", message="priority must be LOW|MEDIUM|HIGH") String priority, + @Pattern(regexp="OPEN|IN_PROGRESS|DONE", message="status must be OPEN|IN_PROGRESS|DONE") String status, LocalDate dueDate, String assigneeSub ) {} // Household tasks (new) – no projectId public record CreateHouseholdTaskRequest( - @NotBlank String title, - String description, - @Pattern(regexp="LOW|MEDIUM|HIGH") String priority, - @Pattern(regexp="OPEN|IN_PROGRESS|DONE") String status, + @NotBlank(message = "title is required") String title, + @Size(max = 8000, message = "description too long") String description, + @Pattern(regexp="LOW|MEDIUM|HIGH", message="priority must be LOW|MEDIUM|HIGH") String priority, + @Pattern(regexp="OPEN|IN_PROGRESS|DONE", message="status must be OPEN|IN_PROGRESS|DONE") String status, LocalDate dueDate, String assigneeSub ) {} public record UpdateTaskRequest( - String title, - String description, - @Pattern(regexp="LOW|MEDIUM|HIGH") String priority, - @Pattern(regexp="OPEN|IN_PROGRESS|DONE") String status, + @Size(min = 1, max = 200, message = "title must be 1..200 characters") String title, + @Size(max = 8000, message = "description too long") String description, + @Pattern(regexp="LOW|MEDIUM|HIGH", message="priority must be LOW|MEDIUM|HIGH") String priority, + @Pattern(regexp="OPEN|IN_PROGRESS|DONE", message="status must be OPEN|IN_PROGRESS|DONE") String status, LocalDate dueDate, String assigneeSub ) {} @@ -57,4 +57,12 @@ public class ProjectTaskDtos { LocalDate dueDate, String assigneeSub ) {} + + // ---- Filters + paging helper ---- + public record TaskFilter( + String status, // OPEN|IN_PROGRESS|DONE + String priority, // LOW|MEDIUM|HIGH + LocalDate dueFrom, + LocalDate dueTo + ) {} }