feat: endurece mutações financeiras e permite zerar conta

This commit is contained in:
Felipe Coutinho
2026-03-20 18:42:18 +00:00
parent f77c64325d
commit e4dd221709
23 changed files with 5490 additions and 2942 deletions

View File

@@ -49,16 +49,17 @@ const DASHBOARD_ENTITIES: ReadonlySet<string> = new Set([
/**
* Revalidates paths for a specific entity.
* Also invalidates the dashboard "use cache" tag for financial entities.
* Also invalidates the user-scoped dashboard cache tag for financial entities.
* @param entity - The entity type
*/
export function revalidateForEntity(
entity: keyof typeof revalidateConfig,
userId: string,
): void {
revalidateConfig[entity].forEach((path) => revalidatePath(path));
// Invalidate dashboard cache for financial mutations
// Invalidate dashboard cache for financial mutations.
if (DASHBOARD_ENTITIES.has(entity)) {
revalidateTag("dashboard", "max");
revalidateTag(`dashboard-${userId}`, "max");
}
}

View File

@@ -15,18 +15,21 @@ export const uuidSchema = (entityName: string = "ID") =>
/**
* Optional/nullable decimal string schema
*/
export const optionalDecimalSchema = z
.string()
.trim()
.optional()
.transform((value) =>
value && value.length > 0 ? value.replace(",", ".") : null,
)
.refine(
(value) => value === null || !Number.isNaN(Number.parseFloat(value)),
"Informe um valor numérico válido.",
)
.transform((value) => (value === null ? null : Number.parseFloat(value)));
export const optionalDecimalSchema = z.union([
z.number().nullable(),
z
.string()
.trim()
.optional()
.transform((value) =>
value && value.length > 0 ? value.replace(",", ".") : null,
)
.refine(
(value) => value === null || !Number.isNaN(Number.parseFloat(value)),
"Informe um valor numérico válido.",
)
.transform((value) => (value === null ? null : Number.parseFloat(value))),
]);
/**
* Day of month schema (1-31)