Skip to main content

@dialstack/sdk / react / sanitizeDestination

Function: sanitizeDestination()

function sanitizeDestination(value, defaultCountry?): string;

Defined in: sdk/src/react/softphone/core/view-model.ts:193

Normalize a user-entered/pasted dial string into what the softphone actually sends: strip display separators (so (581) 319-508215813195082), and — when the result is a valid PSTN number — canonicalize it to E.164 (+1…). Extensions (1001), star/# feature codes (*72), and DTMF (AD) are NOT phone numbers, so they're left as their stripped digits/symbols. The result always fits the server's allowlist, so callers "send something clean".

Idempotent and safe on partial input — use it on paste and as the last step before dialing (per-keystroke, prefer stripToDialString so E.164 conversion doesn't rewrite the field mid-type).

Parameters

value

string

defaultCountry?

CountryCode = 'US'

Returns

string