Zod Utils by Ian Macalinao
    Preparing search index...

    Function zPhoneNumber

    • Generates a Zod schema that validates and formats a phone number to E164 using libphonenumber-js. Attempts to parse the provided value with an optional default country.

      If the phone number is valid, the schema transforms the phone number into an international format (e.g. +358401234567).

      Parameters

      • defaultCountry:
            | undefined
            | CountryCode
            | {
                defaultCallingCode?: string;
                defaultCountry?: CountryCode | undefined;
                extract?: boolean;
            } = undefined

      Returns ZodPhoneNumber