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;