36 lines
1018 B
TypeScript
36 lines
1018 B
TypeScript
import { z } from 'zod';
|
|
// Definir esquema de validación con Zod para el formulario
|
|
export const createUser = z.object({
|
|
username: z.string().min(5, { message: "Debe de tener 5 o más caracteres" }),
|
|
password: z.string().min(8, { message: "Debe de tener 8 o más caracteres" }),
|
|
email: z.string().email({ message: "Correo no válido" }),
|
|
fullname: z.string(),
|
|
phone: z.string(),
|
|
state: z.number(),
|
|
municipality: z.number(),
|
|
parish: z.number(),
|
|
confirmPassword: z.string(),
|
|
})
|
|
.refine((data) => data.password === data.confirmPassword, {
|
|
message: 'La contraseña no coincide',
|
|
path: ['confirmPassword'],
|
|
})
|
|
|
|
export type createUserValue = z.infer<typeof createUser>;
|
|
|
|
export const user = z.object({
|
|
id: z.number().optional(),
|
|
username: z.string(),
|
|
email: z.string(),
|
|
fullname: z.string(),
|
|
phone: z.string().nullable(),
|
|
isActive: z.boolean(),
|
|
role: z.string()
|
|
});
|
|
|
|
export const UsersMutate = z.object({
|
|
message: z.string(),
|
|
data: user,
|
|
})
|
|
|