import { z } from 'zod';

const emailSchema = z
	.email('Please enter a valid email address')
	.max(255, 'Email address cannot exceed 255 characters');

const usernameSchema = z.string().min(1, 'Email is required');

const basePasswordSchema = z.string().min(1, 'Password is required');

const strongPasswordSchema = z.string().min(8, 'Password must be at least 8 characters');

export const loginSchema = z.object({
	email: emailSchema,
	password: basePasswordSchema
});

export const signupSchema = z
	.object({
		email: emailSchema,
		password: strongPasswordSchema,
		confirmPassword: strongPasswordSchema
	})
	.refine((data) => data.password === data.confirmPassword, {
		message: 'Passwords must match',
		path: ['confirmPassword']
	});

export type LoginSchema = typeof loginSchema;
export type SignupSchema = typeof signupSchema;
