33 lines
1.3 KiB
TypeScript
33 lines
1.3 KiB
TypeScript
import { z } from 'zod';
|
|
|
|
export const animalFilterSchema = z.object({
|
|
district: z.string().optional(),
|
|
species: z.enum(['DOG', 'CAT', 'OTHER']).optional(),
|
|
sex: z.enum(['MALE', 'FEMALE']).optional(),
|
|
sterilized: z.coerce.boolean().optional(),
|
|
urgent: z.coerce.boolean().optional(),
|
|
status: z.enum(['AVAILABLE', 'RESERVED', 'ADOPTED']).optional(),
|
|
page: z.coerce.number().int().positive().default(1),
|
|
limit: z.coerce.number().int().min(1).max(50).default(12),
|
|
});
|
|
|
|
export const createAnimalSchema = z.object({
|
|
name: z.string().min(1, 'Nome obrigatório.').max(80),
|
|
species: z.enum(['DOG', 'CAT', 'OTHER']),
|
|
breed: z.string().max(80).optional(),
|
|
ageMonths: z.number().int().min(0).max(300),
|
|
sex: z.enum(['MALE', 'FEMALE']),
|
|
sterilized: z.boolean(),
|
|
urgent: z.boolean().default(false),
|
|
description: z.string().max(2000).optional(),
|
|
shelterId: z.string().cuid(),
|
|
});
|
|
|
|
export const updateAnimalSchema = createAnimalSchema
|
|
.partial()
|
|
.extend({ status: z.enum(['AVAILABLE', 'RESERVED', 'ADOPTED']).optional() });
|
|
|
|
export type AnimalFilter = z.infer<typeof animalFilterSchema>;
|
|
export type CreateAnimalInput = z.infer<typeof createAnimalSchema>;
|
|
export type UpdateAnimalInput = z.infer<typeof updateAnimalSchema>;
|