From 5149373c23b4c350e624ee8b78ba40bac660d673 Mon Sep 17 00:00:00 2001 From: Ricardo <ricardofaria170@gmail.com> Date: Wed, 19 Mar 2025 11:52:45 -0300 Subject: [PATCH] Issue#10 ADD implant validators --- src/validators/implantsValidator.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/validators/implantsValidator.ts b/src/validators/implantsValidator.ts index 70551fc..ee1af3a 100644 --- a/src/validators/implantsValidator.ts +++ b/src/validators/implantsValidator.ts @@ -1,9 +1,10 @@ import { z } from 'zod'; export const implantSchema = z.object({ - id: z.number().int().optional(), - name: z.string().min(1, "Name cannot be empty"), - price: z.number().nonnegative(), - cyberCost: z.number().nonnegative(), - bodyPart: z.string().min(1, "Must be part of something"), -}); \ No newline at end of file + name: z.string().min(1, { message: "Name cannot be empty" }).max(255, { message: "Max of 255 characters" }), + price: z.number().nonnegative({ message: "Price must be positive" }).finite({ message: "Price must be a valid number" }), + cyberCost: z.number().nonnegative({ message: "cyberCost must be positive" }).finite({ message: "cyberCost must be a valid number" }), + bodyPart: z.string().min(1, { message: "Bodypart must be named" }).max(255, { message: "Bodypart cant have more than 255 characters" }), +}); + +export const updateImplantSchema = implantSchema.partial(); \ No newline at end of file -- GitLab