import * as errors from '@@/custom-errors';

export function validatePassword(password: string | undefined): void {
  if (!password || password.length < 12) {
    throw errors.BAD_REQUEST('Password must be at least 12 characters');
  }

  if (!/[a-z]/.test(password)) {
    throw errors.BAD_REQUEST('Password must contain lowercase letters');
  }

  if (!/[A-Z]/.test(password)) {
    throw errors.BAD_REQUEST('Password must contain uppercase letters');
  }

  if (!/[0-9]/.test(password)) {
    throw errors.BAD_REQUEST('Password must contain numbers');
  }

  if (!/[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]/.test(password)) {
    throw errors.BAD_REQUEST('Password must contain special characters (!@#$%^&* etc.)');
  }
}
