@nsf-open/ember-contact-utils
▸ domesticUSPhoneNumber(dependantKey
, defaultValue?
): default
<string
, string
>
Exposes the toDomesticUSPhoneNumber
formatter as an Ember computed decorator that normalizes a
string or number into a standard US telephone number with area code.
public phone = "1234567890"
@domesticUSPhoneNumber('phone')
public formattedPhone!: string; // => "(123) 456-7890"
Name | Type | Default value |
---|---|---|
dependantKey |
string |
undefined |
defaultValue |
string |
'None' |
default
<string
, string
>
▸ toDomesticUSPhoneNumber(value
, defaultValue?
): string
Normalizes a string or number into a standard US telephone number with area code. If a valid string cannot be created, a default value will be returned.
toDomesticUSPhoneNumber("1234567890"); // => "(123) 456-7890"
toDomesticUSPhoneNumber("123-456-7890"); // => "(123) 456-7890"
toDomesticUSPhoneNumber(1234567890); // => "(123) 456-7890"
toDomesticUSPhoneNumber("1234", "N/A"); // => "N/A"
Name | Type | Default value |
---|---|---|
value |
any |
undefined |
defaultValue |
string |
'None' |
string