Skip to content

Instantly share code, notes, and snippets.

@codigoconjuan
Last active November 16, 2024 20:39
Show Gist options
  • Save codigoconjuan/0be4f11d1a77b211f764a0dd16845a65 to your computer and use it in GitHub Desktop.
Save codigoconjuan/0be4f11d1a77b211f764a0dd16845a65 to your computer and use it in GitHub Desktop.
Schema de Validación para Productos en Next.js
export const ProductFormSchema = z.object({
name: z.string()
.min(1, {message: 'El Nombre del Producto no puede ir vacio'}),
price: z.coerce.number({message: 'Precio no válido'})
.min(1, {message: 'El Precio debe ser mayor a 0'}),
inventory: z.coerce.number({message: 'Inventario no válido'})
.min(1, {message: 'El inventario debe ser mayor a 0'}),
categoryId: z.coerce.number({message: 'La Categoria no es válida'})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment