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 {
// 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
) {}
}