import { z } from "zod";

export const CreateDebtSchema = z.object({
  label: z.string().min(1).max(255),
  creditorUserId: z.string().min(1).optional(), // internal household member
  creditor: z.string().max(255).optional(),      // free-text fallback
  totalAmount: z.number().positive("Betrag muss positiv sein"),
  notes: z.string().max(1000).optional(),
});

export const CreateDebtPaymentSchema = z.object({
  debtId: z.string().min(1),
  amount: z.number().positive("Betrag muss positiv sein"),
  date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
  note: z.string().max(255).optional(),
});

export type CreateDebtInput = z.infer<typeof CreateDebtSchema>;
export type CreateDebtPaymentInput = z.infer<typeof CreateDebtPaymentSchema>;
