Skip to main content
System
Phone (string)
string
code reference

Definition

The phone transformer can anonymize an existing phone number or completely generate a new one. There are two phone number transformers that differ by type and the configurations that are available to customize the transformer. This transformer specifically takes a string value and returns a string value. The Phone (integer) transformer takes in an integer value and returns an integer value.

By default, the phone (string) transformer generates a random 10 digit phone number with no hyphens.

For example, the following input value: 7829828714

Would produce the following ouput value: 5698437232

You can see we generated a new phone string value that can be used as an string phone number.

Phone numbers also vary in length with some international phone numbers reaching up to 15 digits in length. You can set this transformer to respect the length of the input value if you're working with phone numbers longer than 10 digits in length. In fact, you can generate a specific international "looking" phone number by specifying the e164 format config.

Configurations

Depending on your validations, you may want to configure the output phone number. As we discussed above, some phone numbers may be longer than the default 10 digits in length. The phone number (string) transformer has the following configurations:

NameDescriptionDefaultExample InputExample Output
Include hyphensIncludes hyphens in the output phone numnber. Note that this config can only be used with default 10 digit phone numbers. false9238724378290-374-8675
PreserveLengthPreserve Length will ensure that the output phone number is the same length as the input phone number.false892387243786243290374867526392
e164 FormatWill output the phone number in e164 format which includes a + sign at the beginning of the phone number.false89238724378+29486752632

Examples

There are several ways you can mix-and-match configurations to get different potential phone number formats. Here are some possible combinations:

PreserveLengthInclude Hyphense164 FormatExample InputExample Output
falsefalsefalse28909237845209273239
falsetruefalse2890923784520-927-3239
truefalsefalse289092378423520927323239
falsefalsetrue2890923784+520922339
truefalsetrue+289092378423+520927323921