correciones en las validaciones de crear-editar productos

This commit is contained in:
2025-06-27 14:38:08 -04:00
parent 2840bbec11
commit f5962efb8b
4 changed files with 35 additions and 55 deletions

View File

@@ -1,7 +1,8 @@
import { z } from 'zod';
export type InventoryTable = z.infer<typeof product>;
export type EditInventory = z.infer<typeof editInventory>;
export type EditInventory = z.infer<typeof editInventory>; //output
export type formDataInput = z.input<typeof editInventory>;
export const product = z.object({
id: z.number().optional(),
@@ -18,7 +19,9 @@ export const editInventory = z.object({
id: z.number().optional(),
title: z.string().min(5, { message: "Debe de tener 5 o más caracteres" }),
description: z.string().min(10, { message: "Debe de tener 10 o más caracteres" }),
stock: z.string().transform(val => Number(val)),
stock: z.string().transform(val => Number(val)).pipe(z.number(
{ invalid_type_error: 'El stock debe ser un número' }).min(0, { message: "El stock debe ser mayor a 0" })
),
price: z.string(),
urlImg: z.string(),
userId: z.number().optional(),