Utilities and Errors
Use international phone helpers and handle typed DOM Package errors
Utilities and Errors
Phone Number Utilities
TiquoPhone provides static helpers for international phone inputs. You do not need to initialize Tiquo to use them.
import { TiquoPhone } from '@tiquo/dom-package';
const phone = TiquoPhone.buildPhone('GB', '07911 123456');
const result = TiquoPhone.validate(phone);
if (result.valid) {
console.log(result.normalized); // +447911123456
}| Method | Purpose |
|---|---|
normalize(phone) | Normalize a number to E.164-style +digits output when possible |
validate(phone) | Return a detailed validation result including normalized value, detected country, or failure reason |
detectCountry(phone) | Detect an ISO country code from the international calling code |
format(phone) | Format an international number for display |
getCountries() | Return the supported country metadata for building a selector |
getDialCode(countryCode) | Return the international dial code for an ISO country code |
buildPhone(countryCode, nationalNumber) | Combine a selected country and national number into normalized international output |
getCountries() returns alphabetically sorted records with code, name, dialCode, format, and flag fields. updateProfile() and createEnquiry() also normalize supplied phone numbers before submission, but validating in the form gives the customer earlier feedback.
Typed Errors
SDK operations reject with TiquoAuthError when the package can provide a structured code:
import { TiquoAuthError } from '@tiquo/dom-package';
try {
await tiquo.verifyOTP(email, code);
} catch (error) {
if (error instanceof TiquoAuthError) {
console.error(error.code, error.message, error.statusCode);
} else {
throw error;
}
}| Property | Type | Description |
|---|---|---|
name | string | TiquoAuthError |
message | string | Human-readable failure message |
code | string | Stable SDK error category for application branching |
statusCode | number or undefined | HTTP status when the error came from an API response |
Common codes include:
| Area | Codes |
|---|---|
| Setup and authentication | MISSING_PUBLIC_KEY, INVALID_PUBLIC_KEY, OTP_SEND_FAILED, OTP_VERIFY_FAILED, NOT_AUTHENTICATED |
| Customer data | PROFILE_UPDATE_FAILED, GET_ORDERS_FAILED, GET_BOOKINGS_FAILED, GET_ENQUIRIES_FAILED, CREATE_ENQUIRY_FAILED |
| Receipts and tickets | GET_RECEIPT_FAILED, RECEIPT_NOT_AVAILABLE, DOWNLOAD_BOOKING_TICKET_FAILED |
| Embeds and catalogs | CONTAINER_NOT_FOUND, MISSING_CUSTOMER_FLOW_ID, CUSTOMER_FLOW_NOT_FOUND, GET_FLOW_SERVICES_FAILED, MISSING_SERVICE_BOOKING_ID, MISSING_MEMBERSHIP_PLAN_ID, IFRAME_TOKEN_FAILED |
| Companies | GET_COMPANIES_FAILED, GET_COLLEAGUES_FAILED, NOT_COMPANY_ADMIN |
Use code for control flow and present an application-owned, customer-friendly message. Preserve statusCode and the original error in internal diagnostics, but never log access tokens, refresh tokens, or OTP values.