Validation tightening (DTOs)

This commit is contained in:
Urban Modig
2025-10-08 19:53:56 +02:00
parent c8dd022395
commit 24c3b7a72c

View File

@ -7,9 +7,9 @@ import java.util.*;
public class ProjectTaskDtos { public class ProjectTaskDtos {
// Projects // Projects
public record CreateProjectRequest( public record CreateProjectRequest(
@NotNull UUID householdId, @NotNull(message = "householdId is required") UUID householdId,
@NotBlank String name, @NotBlank(message = "name is required") String name,
String description @Size(max = 2000, message = "description too long") String description
) {} ) {}
public record ProjectResponse( public record ProjectResponse(
@ -20,30 +20,30 @@ public class ProjectTaskDtos {
// Project tasks (existing) // Project tasks (existing)
public record CreateTaskRequest( public record CreateTaskRequest(
@NotNull UUID projectId, @NotNull(message = "projectId is required") UUID projectId,
@NotBlank String title, @NotBlank(message = "title is required") String title,
String description, @Size(max = 8000, message = "description too long") String description,
@Pattern(regexp="LOW|MEDIUM|HIGH") String priority, @Pattern(regexp="LOW|MEDIUM|HIGH", message="priority must be LOW|MEDIUM|HIGH") String priority,
@Pattern(regexp="OPEN|IN_PROGRESS|DONE") String status, @Pattern(regexp="OPEN|IN_PROGRESS|DONE", message="status must be OPEN|IN_PROGRESS|DONE") String status,
LocalDate dueDate, LocalDate dueDate,
String assigneeSub String assigneeSub
) {} ) {}
// Household tasks (new) no projectId // Household tasks (new) no projectId
public record CreateHouseholdTaskRequest( public record CreateHouseholdTaskRequest(
@NotBlank String title, @NotBlank(message = "title is required") String title,
String description, @Size(max = 8000, message = "description too long") String description,
@Pattern(regexp="LOW|MEDIUM|HIGH") String priority, @Pattern(regexp="LOW|MEDIUM|HIGH", message="priority must be LOW|MEDIUM|HIGH") String priority,
@Pattern(regexp="OPEN|IN_PROGRESS|DONE") String status, @Pattern(regexp="OPEN|IN_PROGRESS|DONE", message="status must be OPEN|IN_PROGRESS|DONE") String status,
LocalDate dueDate, LocalDate dueDate,
String assigneeSub String assigneeSub
) {} ) {}
public record UpdateTaskRequest( public record UpdateTaskRequest(
String title, @Size(min = 1, max = 200, message = "title must be 1..200 characters") String title,
String description, @Size(max = 8000, message = "description too long") String description,
@Pattern(regexp="LOW|MEDIUM|HIGH") String priority, @Pattern(regexp="LOW|MEDIUM|HIGH", message="priority must be LOW|MEDIUM|HIGH") String priority,
@Pattern(regexp="OPEN|IN_PROGRESS|DONE") String status, @Pattern(regexp="OPEN|IN_PROGRESS|DONE", message="status must be OPEN|IN_PROGRESS|DONE") String status,
LocalDate dueDate, LocalDate dueDate,
String assigneeSub String assigneeSub
) {} ) {}
@ -57,4 +57,12 @@ public class ProjectTaskDtos {
LocalDate dueDate, LocalDate dueDate,
String assigneeSub String assigneeSub
) {} ) {}
// ---- Filters + paging helper ----
public record TaskFilter(
String status, // OPEN|IN_PROGRESS|DONE
String priority, // LOW|MEDIUM|HIGH
LocalDate dueFrom,
LocalDate dueTo
) {}
} }