import { z } from 'zod';

export const updatePasswordSchema = z
  .object({
    password: z
      .string()
      .min(8, { message: 'Password must contain at least 8 characters.' })
      .max(32, { message: 'Password must be less than 32 characters.' })
      .regex(
        /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&_])[A-Za-z\d@$!%*?&_]{8,}$/,
        {
          message:
            'Password must contain at least one uppercase letter, one lowercase letter, one number, and one special character (@$!%*?&_).',
        }
      ),
    confirmPassword: z
      .string()
      .min(8, {
        message: 'Password confirmation must contain at least 8 characters.',
      })
      .max(32, {
        message: 'Password confirmation must be less than 32 characters.',
      }),
  })
  .refine(data => data.password === data.confirmPassword, {
    message: 'Passwords do not match.',
    path: ['confirmPassword'],
  });
