import { z } from "zod";

export const signupSchema = z.object({
  username: z
    .string()
    .min(1)
    .max(39)
    .regex(/^[a-zA-Z0-9-]+$/, "Username may only contain letters, numbers, and hyphens"),
  email: z.string().email(),
  password: z.string().min(8).max(128),
});

export const loginSchema = z.object({
  email: z.string().email(),
  password: z.string().min(1),
});

export const createRepoSchema = z.object({
  name: z
    .string()
    .min(1)
    .max(100)
    .regex(/^[a-zA-Z0-9._-]+$/, "Repository name may only contain letters, numbers, dots, hyphens, and underscores"),
  description: z.string().max(280).optional(),
  visibility: z.enum(["public", "private"]).default("public"),
});

export type SignupInput = z.infer<typeof signupSchema>;
export type LoginInput = z.infer<typeof loginSchema>;
export type CreateRepoInput = z.infer<typeof createRepoSchema>;