import {z} from 'zod'
import {Role} from '@/generated/prisma/enums'

export const userSchema = z.object({
  id: z.uuid(),
  email: z.email(),
  password: z
    .string()
    .min(8, {error: 'The password must be at least 8 characters long.'})
    .max(100, {error: "The password can't be longer than 100 characters."}),
  username: z.string().min(3, {error: 'The username must be at least 3 characters long.'}),
  role: z.enum(Role),
})

export const signInSchema = userSchema.omit({id: true, role: true, username: true})

export const registerSchema = userSchema.omit({id: true, role: true})

export const updateUserSchema = userSchema.pick({username: true})
export const updateRoleSchema = userSchema.pick({role: true, id: true})
