36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { z } from 'zod';
|
|
|
|
export const createDonationSchema = z.discriminatedUnion('type', [
|
|
z.object({
|
|
type: z.literal('MONETARY'),
|
|
shelterId: z.string().cuid(),
|
|
details: z.object({
|
|
amount: z.number().min(1, 'Mínimo 1€.').max(10000),
|
|
currency: z.literal('EUR').default('EUR'),
|
|
deliveryMethod: z.literal('payment'),
|
|
}),
|
|
}),
|
|
z.object({
|
|
type: z.literal('FOOD'),
|
|
shelterId: z.string().cuid(),
|
|
details: z.object({
|
|
foodType: z.enum(['dry', 'wet']),
|
|
animalType: z.enum(['dog', 'cat']),
|
|
ageGroup: z.enum(['adult', 'puppy']),
|
|
deliveryMethod: z.enum(['pickup', 'home_delivery']),
|
|
address: z.string().max(200).optional(),
|
|
}),
|
|
}),
|
|
z.object({
|
|
type: z.literal('TOYS'),
|
|
shelterId: z.string().cuid(),
|
|
details: z.object({
|
|
category: z.enum(['chew', 'plush', 'interactive']),
|
|
deliveryMethod: z.enum(['pickup', 'home_delivery']),
|
|
address: z.string().max(200).optional(),
|
|
}),
|
|
}),
|
|
]);
|
|
|
|
export type CreateDonationInput = z.infer<typeof createDonationSchema>;
|