Phone

Format and validate phone numbers with international support.

formatPhone

Formats phone numbers with proper spacing and international dialing codes, supporting multiple output formats for different use cases.

import { formatPhone } from "@tilt-legal/cubitt-components/utilities/formatters";

formatPhone("0412345678"); // "0412 345 678" (AU)
formatPhone("0412345678", { format: "international" }); // "+61 412 345 678"
formatPhone("0412345678", { format: "e164" }); // "+61412345678"
PropertyTypeDefaultDescription
format'national' | 'international' | 'e164' | 'rfc3966''national'Format style
defaultCountryCountryCode'AU'Default country code

isValidPhone

Validates phone numbers against international standards to ensure they're properly formatted and valid for the specified country.

import { isValidPhone } from "@tilt-legal/cubitt-components/utilities/formatters";

isValidPhone("0412345678"); // true
isValidPhone("123"); // false
isValidPhone("02071838750", { defaultCountry: "GB" }); // true
PropertyTypeDefaultDescription
defaultCountryCountryCode'AU'Default country code

On this page