File size: 1,422 Bytes
2b109bf | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | import { z } from 'zod';
import { idParam, listQuery } from '../../common/validators/shared.js';
export const createPlanSchema = z.object({
body: z.object({
name: z.string().min(2),
durationDays: z.coerce.number().int().positive(),
price: z.coerce.number().nonnegative(),
}),
});
export const updatePlanSchema = z.object({
...idParam.shape,
body: z.object({
name: z.string().min(2).optional(),
durationDays: z.coerce.number().int().positive().optional(),
price: z.coerce.number().nonnegative().optional(),
}),
});
export const createSubscriptionSchema = z.object({
body: z.object({
memberId: z.string().uuid(),
planId: z.string().uuid(),
startDate: z.coerce.date().optional(),
}),
});
export const purchaseSubscriptionSchema = z.object({
body: z.object({
planId: z.string().uuid(),
paymentMethod: z.enum(['cash', 'card', 'wallet']),
notes: z.string().max(300).optional(),
}),
});
export const renewSubscriptionSchema = z.object({
...idParam.shape,
body: z.object({
planId: z.string().uuid().optional(),
startDate: z.coerce.date().optional(),
paymentMethod: z.enum(['cash', 'card', 'wallet', 'bank_transfer']).optional(),
}),
});
export const freezeSubscriptionSchema = z.object({
...idParam.shape,
body: z.object({
freezeDays: z.coerce.number().int().positive(),
}),
});
export const listSubscriptionsSchema = listQuery;
|