Initial commit
This commit is contained in:
36
packages/api-contract/src/sport.ts
Normal file
36
packages/api-contract/src/sport.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export const sportSchema = z.object({
|
||||
id: z.uuid(),
|
||||
name: z.string(),
|
||||
slug: z.string(),
|
||||
isActive: z.boolean(),
|
||||
createdAt: z.string().datetime(),
|
||||
updatedAt: z.string().datetime(),
|
||||
})
|
||||
|
||||
export const createSportSchema = z.object({
|
||||
name: z
|
||||
.string()
|
||||
.trim()
|
||||
.min(2, 'El deporte debe tener al menos 2 caracteres.')
|
||||
.max(80, 'El deporte no puede superar los 80 caracteres.'),
|
||||
})
|
||||
|
||||
export const updateSportSchema = z
|
||||
.object({
|
||||
name: z
|
||||
.string()
|
||||
.trim()
|
||||
.min(2, 'El deporte debe tener al menos 2 caracteres.')
|
||||
.max(80, 'El deporte no puede superar los 80 caracteres.')
|
||||
.optional(),
|
||||
isActive: z.boolean().optional(),
|
||||
})
|
||||
.refine((payload) => payload.name !== undefined || payload.isActive !== undefined, {
|
||||
message: 'Debes enviar al menos un campo para actualizar.',
|
||||
})
|
||||
|
||||
export type Sport = z.infer<typeof sportSchema>
|
||||
export type CreateSportInput = z.infer<typeof createSportSchema>
|
||||
export type UpdateSportInput = z.infer<typeof updateSportSchema>
|
||||
Reference in New Issue
Block a user