// src/lib/phone-validation.ts
function normalizeEthiopiaPhone(input) {
  const digits = input.replace(/\D/g, "");
  if (digits.length < 9) {
    return "";
  }
  return `+251${digits.slice(-9)}`;
}
var createPhoneField = (config) => {
  const phoneRegex = config.phone.phoneRegex || /^\+251[79]\d{8}$/;
  const regex = typeof phoneRegex === "string" ? new RegExp(phoneRegex) : phoneRegex;
  return {
    normalize: normalizeEthiopiaPhone,
    validate: (phone) => {
      const n = normalizeEthiopiaPhone(phone);
      if (!n) {
        return false;
      }
      return regex.test(n);
    },
    regex
  };
};
export {
  createPhoneField,
  normalizeEthiopiaPhone
};
//# sourceMappingURL=phone-validation.js.map