/**
 * @ai-summary Generic validation utilities (no business logic)
 * @ai-context Pure functions only, no feature-specific logic
 */

export function isValidEmail(email: string): boolean {
  const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
  return emailRegex.test(email);
}

export function isValidPhone(phone: string): boolean {
  const phoneRegex = /^\+?[\d\s\-()]+$/;
  return phoneRegex.test(phone) && phone.replace(/\D/g, '').length >= 10;
}

export function isValidUUID(uuid: string): boolean {
  const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
  return uuidRegex.test(uuid);
}

export function isValidVIN(vin: string): boolean {
  // VIN must be exactly 17 characters (modern VIN standard since 1981)
  if (vin.length !== 17) return false;

  // VIN cannot contain I, O, or Q
  if (/[IOQ]/i.test(vin)) return false;

  // Must be alphanumeric
  return /^[A-HJ-NPR-Z0-9]{17}$/i.test(vin);
}

export function isValidPreModernVIN(vin: string): boolean {
  // Pre-1981 vehicles had non-standardized VINs of varying lengths (1-17 characters)
  if (vin.length < 1 || vin.length > 17) return false;

  // Must be alphanumeric (allow I, O, Q for pre-1981 as they weren't banned yet)
  return /^[A-Z0-9]+$/i.test(vin);
}