From 95665e5baa92c3e24605c62a3b7102c93559f1c1 Mon Sep 17 00:00:00 2001 From: Spencer Twaddle <7374698+stwaddle@users.noreply.github.com> Date: Sat, 2 May 2026 17:01:55 -0500 Subject: [PATCH] Phase 2: Create zod schemas in src/schemas/index.ts --- src/Budget.Client/src/schemas/index.ts | 48 ++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/Budget.Client/src/schemas/index.ts diff --git a/src/Budget.Client/src/schemas/index.ts b/src/Budget.Client/src/schemas/index.ts new file mode 100644 index 0000000..7159f4a --- /dev/null +++ b/src/Budget.Client/src/schemas/index.ts @@ -0,0 +1,48 @@ +import { z } from 'zod'; + +const frequencyValues = [ + 'Biennial', + 'Annually', + 'Biannually', + 'Quarterly', + 'EveryTwoMonths', + 'Monthly', + 'SemiMonthly', + 'Biweekly', + 'Weekly', +] as const; + +export const createBudgetSchema = z.object({ + name: z.string().min(1, 'Name is required').max(200), +}); + +export const createIncomeSchema = z.object({ + name: z.string().min(1, 'Name is required').max(200), + frequency: z.enum(frequencyValues), + amount: z.coerce.number({ error: 'Amount is required' }).positive('Must be positive'), +}); + +export const createOutgoSchema = z.object({ + name: z.string().min(1, 'Name is required').max(200), + category: z.string().max(100).optional(), + type: z.enum(['Need', 'Want', 'Save']), + frequency: z.enum(frequencyValues), + amount: z.coerce.number().positive('Must be positive'), + paymentSource: z.string().max(100).optional(), + notes: z.string().max(1000).optional(), +}); + +export const createShareSchema = z.object({ + email: z.string().email('Must be a valid email'), + permission: z.enum(['View', 'Edit']), +}); + +export const updateTaxRateSchema = z.object({ + effectiveTaxRate: z.coerce.number().min(0).max(0.99), +}); + +export type CreateBudgetInput = z.infer; +export type CreateIncomeInput = z.infer; +export type CreateOutgoInput = z.infer; +export type CreateShareInput = z.infer; +export type UpdateTaxRateInput = z.infer;