import {string, z} from 'zod'

export const contactSchema = z.object({
  id: z.uuid(),
  userId: z.uuid(),
  firstName: z
    .string()
    .min(3, {error: 'The firstname must be at least 3 characters long.'})
    .max(255, {error: "The firstname can't be longer than 255 characters."}),
  lastName: z
    .string()
    .min(3, {error: 'The firstname must be at least 3 characters long.'})
    .max(255, {error: "The firstname can't be longer than 255 characters."}),
  description: z
    .string()
    .min(10, {error: 'The description must be at least 10 characters long.'})
    .max(255, {error: "The description can't be longer than 255 characters."}),
  avatar: z.string().min(10).max(255),
  contactInfo: z.array(
    z.object({
      type: string().min(3, {error: 'The contact type must be at least 3 characters long.'}),
      value: string().min(3, {error: 'The contact value must be at least 3 characters long.'}),
    }),
  ),
})

export const createContactSchema = contactSchema.omit({id: true, userId: true})
export const updateContactSchema = contactSchema.omit({userId: true})
export const deleteContactSchema = contactSchema.pick({id: true})
export const toggleFavoriteSchema = contactSchema.pick({id: true})
