import { z } from 'zod'; import { CountryCode } from 'libphonenumber-js/min'; export { CountryCode } from 'libphonenumber-js/min'; /** * Options for phone number validation */ interface PhoneNumberOptions { /** Default country code for parsing national numbers */ country?: CountryCode; /** Require the number to be valid (not just possible) */ strict?: boolean; /** Custom error message for invalid phone numbers */ message?: string; /** Custom error message for empty input */ requiredMessage?: string; } /** * Output formats for phone number transformation */ type PhoneOutputFormat = 'e164' | 'national' | 'international' | 'digits' | 'raw'; /** * Transform options for phone number schema */ interface PhoneTransformOptions extends PhoneNumberOptions { /** Output format for the phone number */ format?: PhoneOutputFormat; } /** * Create a Zod phone number validation schema * * @example * ```typescript * import { z } from 'zod' * import { phoneNumber } from 'maskdial/zod' * * // Basic usage * const schema = z.object({ * phone: phoneNumber() * }) * * // With country * const usSchema = z.object({ * phone: phoneNumber({ country: 'US' }) * }) * * // Strict validation (must be valid, not just possible) * const strictSchema = z.object({ * phone: phoneNumber({ country: 'US', strict: true }) * }) * * // Custom error message * const customSchema = z.object({ * phone: phoneNumber({ * country: 'US', * message: 'Please enter a valid US phone number' * }) * }) * ``` */ declare function phoneNumber(options?: PhoneNumberOptions): z.ZodEffects; /** * Create a Zod phone number schema with output transformation * * @example * ```typescript * import { z } from 'zod' * import { phoneNumberTransform } from 'maskdial/zod' * * // Transform to E.164 format * const schema = z.object({ * phone: phoneNumberTransform({ country: 'US', format: 'e164' }) * }) * * // Input: "(202) 555-1234" * // Output: "+12025551234" * ``` */ declare function phoneNumberTransform(options?: PhoneTransformOptions): z.ZodEffects, string, string>; /** * Create an optional phone number schema (allows empty string or undefined) * * @example * ```typescript * import { z } from 'zod' * import { optionalPhoneNumber } from 'maskdial/zod' * * const schema = z.object({ * phone: optionalPhoneNumber({ country: 'US' }) * }) * * // Valid: undefined, "", "(202) 555-1234" * // Invalid: "123" (partial number) * ``` */ declare function optionalPhoneNumber(options?: PhoneNumberOptions): z.ZodEffects, string | undefined, string | undefined>; /** * Zod refinement function for use with existing schemas * * @example * ```typescript * import { z } from 'zod' * import { isValidPhone } from 'maskdial/zod' * * const schema = z.object({ * phone: z.string().refine(isValidPhone('US'), { * message: 'Invalid US phone number' * }) * }) * ``` */ declare function isValidPhone(country?: CountryCode, strict?: boolean): (value: string) => boolean; /** * Create a phone number schema for a specific country with preset options * * @example * ```typescript * import { createCountryPhoneSchema } from 'maskdial/zod' * * const usPhone = createCountryPhoneSchema('US') * const ukPhone = createCountryPhoneSchema('GB') * * const schema = z.object({ * homePhone: usPhone, * workPhone: ukPhone * }) * ``` */ declare function createCountryPhoneSchema(country: CountryCode, options?: Omit): z.ZodEffects; export { type PhoneNumberOptions, type PhoneOutputFormat, type PhoneTransformOptions, createCountryPhoneSchema, phoneNumber as default, isValidPhone, optionalPhoneNumber, phoneNumber, phoneNumberTransform };