import { z } from 'zod'
import { isValidCPF } from '@brazilian-utils/brazilian-utils'

export type Email = {
  sk: string
  email: string
  email_verified: boolean
  email_primary: boolean
}

const isName = (name: string) => name && name.includes(' ')

export const formSchema = z.object({
  name: z
    .string()
    .trim()
    .nonempty('Digite um nome')
    .refine(isName, { message: 'Nome inválido' }),
  email: z.string().trim().toLowerCase(),
  cpf: z
    .string('CPF obrigatório')
    .refine(isValidCPF, { message: 'CPF inválido' })
})

export type Schema = z.infer<typeof formSchema>
