import * as z from 'zod';

export const userSchema = z.object({
  full_name: z.string().min(2, 'Full name must be at least 2 characters'),
  email: z.string().email('Please enter a valid email'),
  username: z
    .string()
    .trim()
    .regex(/^[a-zA-Z0-9._-]+$/, 'Username can use letters, numbers, dot, underscore, and dash')
    .min(3, 'Username must be at least 3 characters')
    .max(50, 'Username must be 50 characters or less')
    .optional()
    .or(z.literal('')),
  password: z.string().optional(),
  employee_code: z.string().optional(),
  department_id: z.string().optional(),
  position_id: z.string().optional(),
  organization_id: z.string().optional(),
  organization_role: z.enum(['admin', 'user']),
  is_active: z.boolean()
});

export type UserFormValues = z.infer<typeof userSchema>;
