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"| Property | Type | Default | Description |
|---|---|---|---|
format | 'national' | 'international' | 'e164' | 'rfc3966' | 'national' | Format style |
defaultCountry | CountryCode | '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| Property | Type | Default | Description |
|---|---|---|---|
defaultCountry | CountryCode | 'AU' | Default country code |